import cookie from 'js-cookie' import { Analytics } from '../../../core/analytics' import { SegmentioSettings } from '../../segmentio' import { ddAnonymizeIPsPlugin } from '..' describe('AnonymizeIPs Plugin', () => { let analytics: Analytics let settings: SegmentioSettings beforeEach(async () => { jest.resetAllMocks() jest.restoreAllMocks() settings = { apiKey: 'foo' } analytics = new Analytics({ writeKey: settings.apiKey, }) await analytics.register(ddAnonymizeIPsPlugin()) }) afterEach(() => { analytics.reset() Object.keys(cookie.get()).map((k) => cookie.remove(k)) window.localStorage.clear() }) it('should remove ip from group calls', async () => { const context = await analytics.group('Group1') const eventContext = context.event.context! expect(eventContext.ip).toBe('0.0.0.0') }) it('should remove ip from identify calls', async () => { const context = await analytics.identify('User1') const eventContext = context.event.context! expect(eventContext.ip).toBe('0.0.0.0') }) it('should remove ip from track calls', async () => { const context = await analytics.track('My Event') const eventContext = context.event.context! expect(eventContext.ip).toBe('0.0.0.0') }) })