Skip to content

Commit

Permalink
tdd for realz
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Dec 20, 2024
1 parent 2629b4f commit 3b849be
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/__tests__/extensions/replay/sessionrecording.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1982,21 +1982,26 @@ describe('SessionRecording', () => {
})
sessionRecording = new SessionRecording(posthog)

expect(sessionRecording['queuedRRWebEvents']).toHaveLength(0)

sessionRecording.onRemoteConfig(makeDecideResponse({ sessionRecording: { endpoint: '/s/' } }))
sessionRecording.startIfEnabledOrStop()
expect(loadScriptMock).toHaveBeenCalled()

expect(sessionRecording['queuedRRWebEvents']).toHaveLength(0)
expect(sessionRecording['queuedRRWebEvents']).toHaveLength(1)

sessionRecording['_tryAddCustomEvent']('test', { test: 'test' })
sessionRecording.startIfEnabledOrStop()
expect(loadScriptMock).toHaveBeenCalled()
})

it('queues events', () => {
expect(sessionRecording['queuedRRWebEvents']).toHaveLength(1)
sessionRecording['_tryAddCustomEvent']('test', { test: 'test' })

expect(sessionRecording['queuedRRWebEvents']).toHaveLength(2)
})

it('limits the queue of events', () => {
expect(sessionRecording['queuedRRWebEvents']).toHaveLength(1)
sessionRecording['_tryAddCustomEvent']('test', { test: 'test' })

expect(sessionRecording['queuedRRWebEvents']).toHaveLength(2)

for (let i = 0; i < 100; i++) {
sessionRecording['_tryAddCustomEvent']('test', { test: 'test' })
Expand Down

0 comments on commit 3b849be

Please sign in to comment.