Skip to content

Commit

Permalink
✅ [rum-recorder] import first test
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitZugmeyer committed Dec 31, 2020
1 parent 04764c0 commit 88dc616
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions packages/rum-recorder/src/domain/rrweb/record.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { createNewEvent } from '@datadog/browser-core'
import { record } from './record'
import { Event, EventType } from './types'

describe('record', () => {
let input: HTMLInputElement
let stop: (() => void) | undefined

beforeEach(() => {
input = document.createElement('input')
document.body.appendChild(input)
})

afterEach(() => {
input.remove()
if (stop) {
stop()
}
})

it('will only have one full snapshot without checkout config', () => {
const emit = jasmine.createSpy<(event: Event) => void>()
stop = record<Event>({ emit })

const count = 30
for (let i = 0; i < count; i += 1) {
input.value += 'a'
input.dispatchEvent(createNewEvent('input', {}))
}

const events = emit.calls.allArgs().map(([event]) => event)
expect(events.length).toEqual(count + 2)
expect(events.filter((event) => event.type === EventType.Meta).length).toEqual(1)
expect(events.filter((event) => event.type === EventType.FullSnapshot).length).toEqual(1)
})
})

0 comments on commit 88dc616

Please sign in to comment.