diff --git a/packages/browser/src/core/buffer/__tests__/index.test.ts b/packages/browser/src/core/buffer/__tests__/index.test.ts index e3576a97d..2fcb4ab15 100644 --- a/packages/browser/src/core/buffer/__tests__/index.test.ts +++ b/packages/browser/src/core/buffer/__tests__/index.test.ts @@ -12,33 +12,31 @@ import { User } from '../../user' describe('PreInitMethodCallBuffer', () => { describe('push', () => { + describe('toArray', () => { + it('should convert the map back to an array', async () => { + const call1 = new PreInitMethodCall('identify', [], jest.fn()) + const call2 = new PreInitMethodCall('identify', [], jest.fn()) + const call3 = new PreInitMethodCall('group', [], jest.fn()) + const buffer = new PreInitMethodCallBuffer(call1, call2, call3) + expect(buffer.toArray()).toEqual([call1, call2, call3]) + }) + }) it('should add method calls', async () => { const call1 = new PreInitMethodCall('identify', [], jest.fn()) const buffer = new PreInitMethodCallBuffer() buffer.push(call1) - expect(buffer.getCalls(call1.method)).toEqual([call1]) + expect(buffer.toArray()).toEqual([call1]) }) - it('should not conflict with pre-existing method calls', async () => { + it('should work if the calls were added at different times or in different ways', async () => { const call1 = new PreInitMethodCall('identify', [], jest.fn()) - const buffer = new PreInitMethodCallBuffer(call1) const call2 = new PreInitMethodCall('identify', [], jest.fn()) const call3 = new PreInitMethodCall('group', [], jest.fn()) - buffer.push(call2, call3) const call4 = new PreInitMethodCall('group', [], jest.fn()) + const buffer = new PreInitMethodCallBuffer(call1) + buffer.push(call2, call3) buffer.push(call4) - expect(buffer.getCalls('identify')).toEqual([call1, call2]) - expect(buffer.getCalls('group')).toEqual([call3, call4]) - }) - }) - - describe('toArray', () => { - it('should convert the map back to an array', async () => { - const call1 = new PreInitMethodCall('identify', [], jest.fn()) - const call2 = new PreInitMethodCall('identify', [], jest.fn()) - const call3 = new PreInitMethodCall('group', [], jest.fn()) - const buffer = new PreInitMethodCallBuffer(call1, call2, call3) - expect(buffer.toArray()).toEqual([call1, call2, call3]) + expect(buffer.toArray()).toEqual([call1, call2, call3, call4]) }) })