mirror of
https://github.com/techno-tim/littlelink-server.git
synced 2024-11-26 06:05:34 +01:00
chore(tests): added tests for umami and google
This commit is contained in:
parent
e0d659ee25
commit
85912e0f70
16
src/analytics/google.test.js
Normal file
16
src/analytics/google.test.js
Normal 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();
|
||||||
|
});
|
16
src/analytics/umami.test.js
Normal file
16
src/analytics/umami.test.js
Normal 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();
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user