|
| 1 | +import { getCurrentScope } from '@sentry/core'; |
| 2 | +import { replayIntegration } from '../../../src/integration'; |
| 3 | +import { getReplay } from '../../../src/util/getReplay'; |
| 4 | +import { TestClient, getDefaultClientOptions } from '../../utils/TestClient'; |
| 5 | + |
| 6 | +describe('getReplay', () => { |
| 7 | + beforeEach(() => { |
| 8 | + getCurrentScope().setClient(undefined); |
| 9 | + }); |
| 10 | + |
| 11 | + it('works without a client', () => { |
| 12 | + const actual = getReplay(); |
| 13 | + expect(actual).toBeUndefined(); |
| 14 | + }); |
| 15 | + |
| 16 | + it('works with a client without Replay', () => { |
| 17 | + const client = new TestClient(getDefaultClientOptions()); |
| 18 | + getCurrentScope().setClient(client); |
| 19 | + |
| 20 | + const actual = getReplay(); |
| 21 | + expect(actual).toBeUndefined(); |
| 22 | + }); |
| 23 | + |
| 24 | + it('works with a client with Replay', () => { |
| 25 | + const replay = replayIntegration(); |
| 26 | + const client = new TestClient( |
| 27 | + getDefaultClientOptions({ |
| 28 | + integrations: [replay], |
| 29 | + replaysOnErrorSampleRate: 0, |
| 30 | + replaysSessionSampleRate: 0, |
| 31 | + }), |
| 32 | + ); |
| 33 | + getCurrentScope().setClient(client); |
| 34 | + client.init(); |
| 35 | + |
| 36 | + const actual = getReplay(); |
| 37 | + expect(actual).toBe(replay); |
| 38 | + expect(replay.getReplayId()).toBe(undefined); |
| 39 | + }); |
| 40 | +}); |
0 commit comments