Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
silesky committed Sep 22, 2023
1 parent 5f56fed commit 57b6607
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions packages/browser/src/core/buffer/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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])
})
})

Expand Down

0 comments on commit 57b6607

Please sign in to comment.