Cleaning up console.log calls in tests

This commit is contained in:
Jeff Avallone 2018-05-28 14:48:10 -04:00
parent 8ba954c743
commit e71f1b4cc2
2 changed files with 12 additions and 0 deletions

View File

@ -38,6 +38,7 @@ describe('setupAnalytics', () => {
describe('when "Do Not Track" is set', () => {
beforeEach(() => {
navigator.doNotTrack = '1';
jest.spyOn(global.console, 'log').mockImplementation(Function.prototype);
});
afterEach(() => {
@ -53,5 +54,10 @@ describe('setupAnalytics', () => {
setupAnalytics();
expect(ReactGA.pageview).not.toHaveBeenCalled();
});
it('logs a message', () => {
setupAnalytics();
expect(global.console.log).toHaveBeenCalledWith('Google Analytics disabled by Do Not Track');
});
});
});

View File

@ -49,6 +49,7 @@ describe('setupRaven', () => {
describe('when "Do Not Track" is set', () => {
beforeEach(() => {
navigator.doNotTrack = '1';
jest.spyOn(global.console, 'log').mockImplementation(Function.prototype);
});
afterEach(() => {
@ -59,5 +60,10 @@ describe('setupRaven', () => {
setupRaven();
expect(Raven.config).not.toHaveBeenCalled();
});
it('logs a message', () => {
setupRaven();
expect(global.console.log).toHaveBeenCalledWith('Sentry error reporting disabled by Do Not Track');
});
});
});