chore(tests): added tests for umami and google

This commit is contained in:
Timothy Stewart 2021-10-16 17:16:19 -05:00
parent e0d659ee25
commit 85912e0f70
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,16 @@
import { trackGoogleEvent } from './google';
it('should call gtag with event', () => {
const mockedGtag = jest.fn();
const originalWindow = { ...window };
const windowSpy = jest.spyOn(global, 'window', 'get');
windowSpy.mockImplementation(() => ({
...originalWindow,
gtag: mockedGtag,
}));
trackGoogleEvent('youtube-button');
expect(mockedGtag).toBeCalledWith('event', 'youtube-button');
windowSpy.mockRestore();
});

View File

@ -0,0 +1,16 @@
import { trackUmamiEvent } from './umami';
it('should call gtag with event', () => {
const mockedUmami = jest.fn();
const originalWindow = { ...window };
const windowSpy = jest.spyOn(global, 'window', 'get');
windowSpy.mockImplementation(() => ({
...originalWindow,
umami: mockedUmami,
}));
trackUmamiEvent('youtube-button');
expect(mockedUmami).toBeCalledWith('youtube-button');
windowSpy.mockRestore();
});