chore(tests): cleaned up

This commit is contained in:
Timothy Stewart 2021-10-16 22:14:16 -05:00
parent 99cf1bc7de
commit 189fee14cb
2 changed files with 13 additions and 13 deletions

View File

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

View File

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