Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
neilkakkar committed Oct 25, 2023
1 parent 0eb83a3 commit b423345
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/__tests__/extensions/surveys.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,16 @@ describe('survey display logic', () => {
expect(mockPostHog.capture).toBeCalledTimes(1)
})

test('when url changes, callSurveys runs again', () => {
test('callSurveys runs on interval irrespective of url change', () => {
jest.useFakeTimers()
jest.spyOn(global, 'setInterval')
generateSurveys(mockPostHog)
expect(mockPostHog.getActiveMatchingSurveys).toBeCalledTimes(1)
expect(setInterval).toHaveBeenLastCalledWith(expect.any(Function), 1500)
expect(setInterval).toHaveBeenLastCalledWith(expect.any(Function), 3000)

jest.advanceTimersByTime(3000)
expect(mockPostHog.getActiveMatchingSurveys).toBeCalledTimes(2)
expect(setInterval).toHaveBeenLastCalledWith(expect.any(Function), 3000)
})

test('multiple choice type question elements are unique', () => {
Expand Down

0 comments on commit b423345

Please sign in to comment.