diff --git a/src/services/analytics/__tests__/gtm.test.ts b/src/services/analytics/__tests__/gtm.test.ts index e472376da4..5381ec244c 100644 --- a/src/services/analytics/__tests__/gtm.test.ts +++ b/src/services/analytics/__tests__/gtm.test.ts @@ -11,35 +11,11 @@ jest.mock('../TagManager', () => ({ setUserProperty: jest.fn(), })) -const FAKE_SAFE_APP_NAME = 'Safe App' -const FAKE_DOMAIN = 'http://domain.crypto' - describe('gtm', () => { // Reset mocks before each test beforeEach(() => { jest.clearAllMocks() }) - describe('normalizeAppName', () => { - it('should return the app name if is not an URL', () => { - expect(gtm.normalizeAppName(FAKE_SAFE_APP_NAME)).toBe(FAKE_SAFE_APP_NAME) - }) - - it('should strip the querystring or hash when is an URL', () => { - expect(gtm.normalizeAppName(FAKE_DOMAIN)).toBe(FAKE_DOMAIN) - expect(gtm.normalizeAppName(`${FAKE_DOMAIN}?q1=query1&q2=query2`)).toBe(FAKE_DOMAIN) - expect(gtm.normalizeAppName(`${FAKE_DOMAIN}#hash`)).toBe(FAKE_DOMAIN) - }) - }) - - describe('gtmInit', () => { - gtm.gtmInit() - - expect(TagManager.initialize).toHaveBeenCalledWith({ - auth: expect.any(String), - gtmId: expect.any(String), - preview: 'env-3', - }) - }) describe('gtmTrack', () => { it('should send correct data to the dataLayer', () => { @@ -136,5 +112,20 @@ describe('gtm', () => { }), ) }) + + describe('normalizeAppName', () => { + const FAKE_SAFE_APP_NAME = 'Safe App' + const FAKE_DOMAIN = 'http://domain.crypto' + + it('should return the app name if is not an URL', () => { + expect(gtm.normalizeAppName(FAKE_SAFE_APP_NAME)).toBe(FAKE_SAFE_APP_NAME) + }) + + it('should strip the querystring or hash when is an URL', () => { + expect(gtm.normalizeAppName(FAKE_DOMAIN)).toBe(FAKE_DOMAIN) + expect(gtm.normalizeAppName(`${FAKE_DOMAIN}?q1=query1&q2=query2`)).toBe(FAKE_DOMAIN) + expect(gtm.normalizeAppName(`${FAKE_DOMAIN}#hash`)).toBe(FAKE_DOMAIN) + }) + }) }) })