diff --git a/packages/browser/src/browser/__tests__/integration.test.ts b/packages/browser/src/browser/__tests__/integration.test.ts index b03740945..893ac757d 100644 --- a/packages/browser/src/browser/__tests__/integration.test.ts +++ b/packages/browser/src/browser/__tests__/integration.test.ts @@ -17,6 +17,9 @@ import { } from '../../test-helpers/test-writekeys' import { PriorityQueue } from '../../lib/priority-queue' import { getCDN, setGlobalCDNUrl } from '../../lib/parse-cdn' +import { UniversalStorage } from '../../core/user' + +const storage = {} as UniversalStorage // eslint-disable-next-line @typescript-eslint/no-explicit-any let fetchCalls: Array[] = [] @@ -847,7 +850,8 @@ describe('retries', () => { throw new Error('aaay') }, }, - ajs + ajs, + storage ) // Dispatching an event will push it into the priority queue. @@ -875,7 +879,8 @@ describe('retries', () => { ready: () => Promise.resolve(true), track: (ctx) => ctx, }, - ajs + ajs, + storage ) // @ts-ignore ignore reassining function diff --git a/packages/browser/src/core/queue/__tests__/event-queue.test.ts b/packages/browser/src/core/queue/__tests__/event-queue.test.ts index 20c2a800b..8800908aa 100644 --- a/packages/browser/src/core/queue/__tests__/event-queue.test.ts +++ b/packages/browser/src/core/queue/__tests__/event-queue.test.ts @@ -11,6 +11,9 @@ import { Context, ContextCancelation } from '../../context' import { Plugin } from '../../plugin' import { EventQueue } from '../event-queue' import { pTimeout } from '../../callback' +import { UniversalStorage } from '../../user' + +const storage = {} as UniversalStorage async function flushAll(eq: EventQueue): Promise { const flushSpy = jest.spyOn(eq, 'flush') @@ -148,7 +151,8 @@ describe('Flushing', () => { return Promise.resolve(ctx) }, }, - ajs + ajs, + storage ) eq.dispatch(fruitBasket) @@ -218,7 +222,8 @@ describe('Flushing', () => { return Promise.resolve(ctx) }, }, - ajs + ajs, + storage ) eq.dispatch(fruitBasket) @@ -256,7 +261,8 @@ describe('Flushing', () => { return ctx }, }, - ajs + ajs, + storage ) const dispatches = [ @@ -293,7 +299,8 @@ describe('Flushing', () => { return ctx }, }, - ajs + ajs, + storage ) const context = await eq.dispatchSingle(fruitBasket) @@ -320,7 +327,8 @@ describe('Flushing', () => { return Promise.resolve(ctx) }, }, - ajs + ajs, + storage ) eq.dispatch(fruitBasket) @@ -361,7 +369,8 @@ describe('Flushing', () => { return Promise.resolve(ctx) }, }, - ajs + ajs, + storage ) const fruitBasketDelivery = eq.dispatch(fruitBasket) @@ -428,9 +437,9 @@ describe('Flushing', () => { const ctx = new Context(evt) - await eq.register(Context.system(), amplitude, ajs) - await eq.register(Context.system(), mixPanel, ajs) - await eq.register(Context.system(), segmentio, ajs) + await eq.register(Context.system(), amplitude, ajs, storage) + await eq.register(Context.system(), mixPanel, ajs, storage) + await eq.register(Context.system(), segmentio, ajs, storage) eq.dispatch(ctx) @@ -461,9 +470,9 @@ describe('Flushing', () => { const ctx = new Context(evt) - await eq.register(Context.system(), amplitude, ajs) - await eq.register(Context.system(), mixPanel, ajs) - await eq.register(Context.system(), segmentio, ajs) + await eq.register(Context.system(), amplitude, ajs, storage) + await eq.register(Context.system(), mixPanel, ajs, storage) + await eq.register(Context.system(), segmentio, ajs, storage) eq.dispatch(ctx) @@ -495,9 +504,9 @@ describe('Flushing', () => { const ctx = new Context(evt) - await eq.register(Context.system(), amplitude, ajs) - await eq.register(Context.system(), mixPanel, ajs) - await eq.register(Context.system(), segmentio, ajs) + await eq.register(Context.system(), amplitude, ajs, storage) + await eq.register(Context.system(), mixPanel, ajs, storage) + await eq.register(Context.system(), segmentio, ajs, storage) eq.dispatch(ctx) @@ -529,9 +538,9 @@ describe('Flushing', () => { const ctx = new Context(evt) - await eq.register(Context.system(), amplitude, ajs) - await eq.register(Context.system(), mixPanel, ajs) - await eq.register(Context.system(), segmentio, ajs) + await eq.register(Context.system(), amplitude, ajs, storage) + await eq.register(Context.system(), mixPanel, ajs, storage) + await eq.register(Context.system(), segmentio, ajs, storage) eq.dispatch(ctx) @@ -562,9 +571,9 @@ describe('Flushing', () => { const ctx = new Context(evt) - await eq.register(Context.system(), amplitude, ajs) - await eq.register(Context.system(), mixPanel, ajs) - await eq.register(Context.system(), segmentio, ajs) + await eq.register(Context.system(), amplitude, ajs, storage) + await eq.register(Context.system(), mixPanel, ajs, storage) + await eq.register(Context.system(), segmentio, ajs, storage) eq.dispatch(ctx) @@ -597,8 +606,8 @@ describe('Flushing', () => { const ctx = new Context(evt) - await eq.register(Context.system(), amplitude, ajs) - await eq.register(Context.system(), segmentio, ajs) + await eq.register(Context.system(), amplitude, ajs, storage) + await eq.register(Context.system(), segmentio, ajs, storage) eq.dispatch(ctx) @@ -628,9 +637,9 @@ describe('Flushing', () => { } const ctx = new Context(evt) - await eq.register(Context.system(), amplitude, ajs) - await eq.register(Context.system(), mixPanel, ajs) - await eq.register(Context.system(), segmentio, ajs) + await eq.register(Context.system(), amplitude, ajs, storage) + await eq.register(Context.system(), mixPanel, ajs, storage) + await eq.register(Context.system(), segmentio, ajs, storage) await eq.dispatch(ctx) const skipAmplitudeAndSegment: MiddlewareFunction = ({ @@ -649,7 +658,8 @@ describe('Flushing', () => { await eq.register( Context.system(), sourceMiddlewarePlugin(skipAmplitudeAndSegment, {}), - ajs + ajs, + storage ) await eq.dispatch(ctx) @@ -667,7 +677,9 @@ describe('deregister', () => { const toBeRemoved = { ...testPlugin, name: 'remove-me' } const plugins = [testPlugin, toBeRemoved] - const promises = plugins.map((p) => eq.register(Context.system(), p, ajs)) + const promises = plugins.map((p) => + eq.register(Context.system(), p, ajs, storage) + ) await Promise.all(promises) await eq.deregister(Context.system(), toBeRemoved, ajs) @@ -680,7 +692,9 @@ describe('deregister', () => { const toBeRemoved = { ...testPlugin, name: 'remove-me', unload: jest.fn() } const plugins = [testPlugin, toBeRemoved] - const promises = plugins.map((p) => eq.register(Context.system(), p, ajs)) + const promises = plugins.map((p) => + eq.register(Context.system(), p, ajs, storage) + ) await Promise.all(promises) await eq.deregister(Context.system(), toBeRemoved, ajs) @@ -743,7 +757,8 @@ describe('dispatchSingle', () => { return Promise.resolve(ctx) }, }, - ajs + ajs, + storage ) expect(eq.queue.length).toBe(0)