|
1 | 1 | import jsdom, { JSDOM } from 'jsdom' |
2 | | -import { InitOptions } from '../../' |
| 2 | +import { InitOptions, getGlobalAnalytics } from '../../' |
3 | 3 | import { AnalyticsBrowser, loadLegacySettings } from '../../browser' |
4 | 4 | import { snippet } from '../../tester/__fixtures__/segment-snippet' |
5 | | -import { install, AnalyticsStandalone } from '../standalone-analytics' |
| 5 | +import { install } from '../standalone-analytics' |
6 | 6 | import unfetch from 'unfetch' |
7 | 7 | import { PersistedPriorityQueue } from '../../lib/priority-queue/persisted' |
8 | 8 | import { sleep } from '../../lib/sleep' |
9 | 9 | import * as Factory from '../../test-helpers/factories' |
10 | 10 | import { EventQueue } from '../../core/queue/event-queue' |
| 11 | +import { AnalyticsStandalone } from '../standalone-interface' |
11 | 12 |
|
12 | 13 | const track = jest.fn() |
13 | 14 | const identify = jest.fn() |
@@ -142,7 +143,7 @@ describe('standalone bundle', () => { |
142 | 143 | .mockImplementation((): Promise<Response> => fetchSettings) |
143 | 144 | const mockCdn = 'http://my-overridden-cdn.com' |
144 | 145 |
|
145 | | - window.analytics._cdn = mockCdn |
| 146 | + getGlobalAnalytics()!._cdn = mockCdn |
146 | 147 | await loadLegacySettings(segmentDotCom) |
147 | 148 |
|
148 | 149 | expect(unfetch).toHaveBeenCalledWith(expect.stringContaining(mockCdn)) |
@@ -262,7 +263,7 @@ describe('standalone bundle', () => { |
262 | 263 |
|
263 | 264 | // register is called after flushPreBuffer in `loadAnalytics` |
264 | 265 | register.mockImplementationOnce(() => |
265 | | - window.analytics.track('race conditions', { foo: 'bar' }) |
| 266 | + getGlobalAnalytics()?.track('race conditions', { foo: 'bar' }) |
266 | 267 | ) |
267 | 268 |
|
268 | 269 | await install() |
|
0 commit comments