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';
it('should call gtag with event', () => {
describe('google.js', () => {
const mockedGtag = jest.fn();
const originalWindow = { ...window };
const windowSpy = jest.spyOn(global, 'window', 'get');
@ -8,9 +8,9 @@ it('should call gtag with event', () => {
...originalWindow,
gtag: mockedGtag,
}));
trackGoogleEvent('youtube-button');
expect(mockedGtag).toBeCalledWith('event', 'youtube-button');
windowSpy.mockRestore();
it('should call gtag with event', () => {
trackGoogleEvent('youtube-button');
expect(mockedGtag).toBeCalledWith('event', 'youtube-button');
windowSpy.mockRestore();
});
});

View File

@ -1,16 +1,16 @@
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 originalWindow = { ...window };
const windowSpy = jest.spyOn(global, 'window', 'get');
windowSpy.mockImplementation(() => ({
...originalWindow,
umami: mockedUmami,
}));
trackUmamiEvent('youtube-button');
expect(mockedUmami).toBeCalledWith('youtube-button');
windowSpy.mockRestore();
it('should call umami with event', () => {
trackUmamiEvent('youtube-button');
expect(mockedUmami).toBeCalledWith('youtube-button');
windowSpy.mockRestore();
});
});