|
| 1 | +import { getCurrentScope } from '@sentry/core'; |
| 2 | +import { replayIntegration } from '../../../src/integration'; |
| 3 | +import { getReplay } from '../../../src/util/getReplay'; |
| 4 | +import { getDefaultClientOptions, init } 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 | + init( |
| 18 | + getDefaultClientOptions({ |
| 19 | + dsn: 'https://[email protected]/1', |
| 20 | + }), |
| 21 | + ); |
| 22 | + |
| 23 | + const actual = getReplay(); |
| 24 | + expect(actual).toBeUndefined(); |
| 25 | + }); |
| 26 | + |
| 27 | + it('works with a client with Replay xxx', () => { |
| 28 | + const replay = replayIntegration(); |
| 29 | + init( |
| 30 | + getDefaultClientOptions({ |
| 31 | + integrations: [replay], |
| 32 | + replaysOnErrorSampleRate: 0, |
| 33 | + replaysSessionSampleRate: 0, |
| 34 | + }), |
| 35 | + ); |
| 36 | + |
| 37 | + const actual = getReplay(); |
| 38 | + expect(actual).toBeDefined(); |
| 39 | + expect(actual === replay).toBe(true); |
| 40 | + expect(replay.getReplayId()).toBe(undefined); |
| 41 | + }); |
| 42 | +}); |
0 commit comments