Files
moreminimore-chat/app/javascript/dashboard/helper/AnalyticsHelper/specs/helper.spec.js
2026-08-15 23:27:09 +07:00

52 lines
1.4 KiB
JavaScript

import helperObject, { AnalyticsHelper } from '../';
describe('helperObject', () => {
it('keeps the compatibility object as an AnalyticsHelper instance', () => {
expect(helperObject).toBeInstanceOf(AnalyticsHelper);
});
});
describe('AnalyticsHelper', () => {
let analyticsHelper;
beforeEach(() => {
analyticsHelper = new AnalyticsHelper({ token: 'test_token' });
});
it('never initializes a provider, even when a token is supplied', async () => {
await expect(analyticsHelper.init()).resolves.toBeUndefined();
expect(analyticsHelper.analytics).toBeNull();
});
it('keeps identify as a no-op and does not retain user data', () => {
expect(
analyticsHelper.identify({
id: 123,
email: 'person@example.invalid',
name: 'Test User',
accounts: [{ id: 1, name: 'Test Account' }],
account_id: 1,
})
).toBeUndefined();
expect(analyticsHelper.user).toEqual({});
});
it('keeps track as a no-op and does not retain event data', () => {
expect(
analyticsHelper.track('Test Event', {
email: 'person@example.invalid',
account_id: 1,
})
).toBeUndefined();
expect(analyticsHelper.analytics).toBeNull();
});
it('keeps page as a no-op and does not retain page data', () => {
expect(
analyticsHelper.page('home', { path: '/dashboard' })
).toBeUndefined();
expect(analyticsHelper.analytics).toBeNull();
});
});