Skip to content

Commit

Permalink
chore: Add test for reset() and anonymous users (#1444)
Browse files Browse the repository at this point in the history
  • Loading branch information
robbie-c authored Sep 30, 2024
1 parent 65eb083 commit f09f334
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/__tests__/personProcessing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,4 +529,22 @@ describe('person processing', () => {
expect(jest.mocked(logger).error).toBeCalledTimes(0)
})
})

describe('reset', () => {
it('should revert a back to anonymous state in identified_only', async () => {
// arrange
const { posthog, onCapture } = await setup('identified_only')
posthog.identify(distinctId)
posthog.capture('custom event before reset')

// act
posthog.reset()
posthog.capture('custom event after reset')

// assert
expect(posthog._isIdentified()).toBe(false)
expect(onCapture.mock.calls.length).toEqual(3)
expect(onCapture.mock.calls[2][1].properties.$process_person_profile).toEqual(false)
})
})
})

0 comments on commit f09f334

Please sign in to comment.