mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-07 22:46:13 +01:00
139d7d9f0f
- angular-google-analytics plugin update from 0.0.15 to 1.1.7 - google analytics config moved into secrets.yml/production
79 lines
2.4 KiB
JavaScript
79 lines
2.4 KiB
JavaScript
/* global afterEach, before, beforeEach, describe, document, expect, inject, it, module, spyOn */
|
|
'use strict';
|
|
|
|
describe('disable analytics / user opt-out', function () {
|
|
beforeEach(module('angular-google-analytics'));
|
|
beforeEach(module(function (AnalyticsProvider) {
|
|
AnalyticsProvider
|
|
.setAccount('UA-XXXXXX-xx')
|
|
.logAllCalls(true)
|
|
.enterTestMode();
|
|
}));
|
|
|
|
afterEach(inject(function (Analytics) {
|
|
Analytics.log.length = 0; // clear log
|
|
}));
|
|
|
|
describe('with universal analytics', function () {
|
|
beforeEach(module(function (AnalyticsProvider) {
|
|
AnalyticsProvider.useAnalytics(true);
|
|
}));
|
|
|
|
it('should be enabled by default', function () {
|
|
inject(function (Analytics) {
|
|
expect(Analytics.configuration.disableAnalytics).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('when disabled', function () {
|
|
beforeEach(module(function (AnalyticsProvider) {
|
|
AnalyticsProvider.disableAnalytics(true);
|
|
}));
|
|
|
|
it('should be disabled', function () {
|
|
inject(function (Analytics) {
|
|
expect(Analytics.configuration.disableAnalytics).toBe(true);
|
|
});
|
|
});
|
|
|
|
it('should log an info message about the account being disabled', function () {
|
|
inject(function (Analytics, $window) {
|
|
expect(Analytics.log[0]).toEqual([ 'info', 'Analytics disabled: UA-XXXXXX-xx' ]);
|
|
expect($window['ga-disable-UA-XXXXXX-xx']).toBe(true);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('with classic analytics', function () {
|
|
beforeEach(module(function (AnalyticsProvider) {
|
|
AnalyticsProvider.useAnalytics(false);
|
|
}));
|
|
|
|
it('should be enabled by default', function () {
|
|
inject(function (Analytics) {
|
|
expect(Analytics.configuration.disableAnalytics).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe('when disabled', function () {
|
|
beforeEach(module(function (AnalyticsProvider) {
|
|
AnalyticsProvider.disableAnalytics(true);
|
|
}));
|
|
|
|
it('should be disabled', function () {
|
|
inject(function (Analytics) {
|
|
expect(Analytics.configuration.disableAnalytics).toBe(true);
|
|
});
|
|
});
|
|
|
|
it('should log an info message about the account being disabled', function () {
|
|
inject(function (Analytics, $window) {
|
|
expect(Analytics.log[0]).toEqual([ 'info', 'Analytics disabled: UA-XXXXXX-xx' ]);
|
|
expect($window['ga-disable-UA-XXXXXX-xx']).toBe(true);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|