1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-08 23:46:14 +01:00
fab-manager/vendor/assets/components/angular-google-analytics/test/unit/debug-mode.js

90 lines
2.7 KiB
JavaScript
Raw Normal View History

/* global afterEach, before, beforeEach, describe, document, expect, inject, it, module, spyOn */
'use strict';
describe('universal analytics debug mode', function () {
beforeEach(module('angular-google-analytics'));
beforeEach(module(function (AnalyticsProvider) {
AnalyticsProvider
.setAccount('UA-XXXXXX-xx')
.useAnalytics(true)
.logAllCalls(true)
.enterTestMode();
}));
afterEach(inject(function (Analytics) {
Analytics.log.length = 0; // clear log
}));
it('should have debug mode disabled by default', function () {
inject(function (Analytics) {
expect(Analytics.configuration.debugMode).toBe(false);
});
});
it('should have trace debugging mode disabled by default', function () {
inject(function (Analytics) {
expect(Analytics.configuration.traceDebuggingMode).toBe(false);
});
});
describe('without trace debugging mode', function () {
beforeEach(module(function (AnalyticsProvider) {
AnalyticsProvider.enterDebugMode();
}));
it('should have debug mode enabled', function () {
inject(function (Analytics) {
expect(Analytics.configuration.debugMode).toBe(true);
});
});
it('should have trace debugging disabled', function () {
inject(function (Analytics) {
expect(Analytics.configuration.traceDebuggingMode).toBe(false);
});
});
it('should inject the analytics debug script', function () {
inject(function (Analytics) {
expect(Analytics.log[0]).toEqual(['inject', '//www.google-analytics.com/analytics_debug.js']);
});
});
it('should not set the analytics trace debugging variable', function () {
inject(function (Analytics, $window) {
expect($window.ga_debug).toEqual(undefined);
});
});
});
describe('with trace debugging mode', function () {
beforeEach(module(function (AnalyticsProvider) {
AnalyticsProvider.enterDebugMode(true);
}));
it('should have debug mode enabled', function () {
inject(function (Analytics) {
expect(Analytics.configuration.debugMode).toBe(true);
});
});
it('should have trace debugging enabled', function () {
inject(function (Analytics) {
expect(Analytics.configuration.traceDebuggingMode).toBe(true);
});
});
it('should inject the analytics debug script', function () {
inject(function (Analytics) {
expect(Analytics.log[0]).toEqual(['inject', '//www.google-analytics.com/analytics_debug.js']);
});
});
it('should set the analytics trace debugging variable', function () {
inject(function (Analytics, $window) {
expect($window.ga_debug).toEqual({ trace: true });
});
});
});
});