From f09f334bb63b4b7474bcfb5493f0b7ca9473dbe2 Mon Sep 17 00:00:00 2001 From: Robbie Date: Mon, 30 Sep 2024 14:05:57 +0100 Subject: [PATCH] chore: Add test for reset() and anonymous users (#1444) --- src/__tests__/personProcessing.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/__tests__/personProcessing.test.ts b/src/__tests__/personProcessing.test.ts index 35531594d..312fc8cb9 100644 --- a/src/__tests__/personProcessing.test.ts +++ b/src/__tests__/personProcessing.test.ts @@ -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) + }) + }) })