diff --git a/test/spec/services/analyticsServicesSpec.js b/test/spec/services/analyticsServicesSpec.js index ee1fa936a1..a03b962694 100644 --- a/test/spec/services/analyticsServicesSpec.js +++ b/test/spec/services/analyticsServicesSpec.js @@ -15,11 +15,7 @@ describe('Analytics Service', function () { context('error handling', function() { beforeEach(function() { - sinon.stub(console, 'log'); - }); - - afterEach(function() { - console.log.restore(); + sandbox.stub(console, 'log'); }); it('does not accept tracking events without required properties', function() { @@ -42,15 +38,9 @@ describe('Analytics Service', function () { context('Amplitude', function() { beforeEach(function() { - sinon.stub(amplitude, 'setUserId'); - sinon.stub(amplitude, 'logEvent'); - sinon.stub(amplitude, 'setUserProperties'); - }); - - afterEach(function() { - amplitude.setUserId.restore(); - amplitude.logEvent.restore(); - amplitude.setUserProperties.restore(); + sandbox.stub(amplitude, 'setUserId'); + sandbox.stub(amplitude, 'logEvent'); + sandbox.stub(amplitude, 'setUserProperties'); }); it('sets up tracking when user registers', function() { @@ -85,11 +75,7 @@ describe('Analytics Service', function () { context('Google Analytics', function() { beforeEach(function() { - sinon.stub(window, 'ga'); - }); - - afterEach(function() { - window.ga.restore(); + sandbox.stub(window, 'ga'); }); it('sets up tracking when user registers', function() { @@ -126,17 +112,10 @@ describe('Analytics Service', function () { context.skip('Mixpanel', function() { // Mixpanel not currently in use beforeEach(function() { - sinon.stub(mixpanel, 'alias'); - sinon.stub(mixpanel, 'identify'); - sinon.stub(mixpanel, 'track'); - sinon.stub(mixpanel, 'register'); - }); - - afterEach(function() { - mixpanel.alias.restore(); - mixpanel.identify.restore(); - mixpanel.track.restore(); - mixpanel.register.restore(); + sandbox.stub(mixpanel, 'alias'); + sandbox.stub(mixpanel, 'identify'); + sandbox.stub(mixpanel, 'track'); + sandbox.stub(mixpanel, 'register'); }); it('sets up tracking when user registers', function() {