Skip to content
This repository was archived by the owner on Aug 14, 2019. It is now read-only.

Commit a3619c4

Browse files
committed
Correct casing on parameter name
1 parent 4af19c9 commit a3619c4

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

test/index.test.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var plugin = require('../lib/');
88
// GA saves arrays as argument objects and `assert.deepEquals` fails when comparing
99
// argument objects against arrays!
1010
var toArray = require('to-array');
11+
var _ = require('lodash');
1112

1213
describe('Google Analytics', function() {
1314
var GA = plugin.Integration;
@@ -64,7 +65,7 @@ describe('Google Analytics', function() {
6465
siteSpeedSampleRate: 42,
6566
sampleRate: 15,
6667
trackingId: 'UA-27033709-12',
67-
useGoogleAmpClientId: false
68+
useGooleAmpClientId: false
6869
};
6970

7071
beforeEach(function() {
@@ -129,7 +130,14 @@ describe('Google Analytics', function() {
129130
if (window.location.hostname !== 'localhost') expectedOpts.cookieDomain = 'auto';
130131
analytics.initialize();
131132
analytics.page();
132-
analytics.deepEqual(toArray(window.ga.q[0]), ['create', settings.trackingId, expectedOpts]);
133+
134+
// some workaround for useGoogleAmpClientId as the name passed to GA needed to change to useAMPclientID
135+
// but the tests expect the option name to == the parameter passed
136+
var expectedOptsOmitAmp = _.omit(expectedOpts,['useGoogleAmpClientId']);
137+
var gaOptsOmitAmp = _.omit(window.ga.q[0][2],'useAMPclientID');
138+
window.ga.q[0][2] = gaOptsOmitAmp;
139+
140+
analytics.deepEqual(toArray(window.ga.q[0]), ['create', settings.trackingId, expectedOptsOmitAmp]);
133141
});
134142

135143
it('should name ga tracker if opted in', function() {
@@ -144,22 +152,35 @@ describe('Google Analytics', function() {
144152
ga.options.nameTracker = true;
145153
analytics.initialize();
146154
analytics.page();
147-
analytics.deepEqual(toArray(window.ga.q[0]), ['create', settings.trackingId, expectedOpts]);
155+
156+
// some workaround for useGoogleAmpClientId as the name passed to GA needed to change to useAMPclientID
157+
// but the tests expect the option name to == the parameter passed
158+
var expectedOptsOmitAmp = _.omit(expectedOpts,['useGoogleAmpClientId']);
159+
var gaOptsOmitAmp = _.omit(window.ga.q[0][2],'useAMPclientID');
160+
window.ga.q[0][2] = gaOptsOmitAmp;
161+
162+
analytics.deepEqual(toArray(window.ga.q[0]), ['create', settings.trackingId, expectedOptsOmitAmp]);
148163
});
149164

150165
it('should use AMP Id as the Client Id if the setting is enabled', function() {
151-
ga.options.useAmpClientId = true;
166+
ga.options.useAMPclientID = true;
152167
var expectedOpts = {
153168
cookieDomain: 'none',
169+
useGoogleAmpClientId: true,
154170
siteSpeedSampleRate: settings.siteSpeedSampleRate,
155171
sampleRate: settings.sampleRate,
156-
allowLinker: true,
157-
useGoogleAmpClientId: true
172+
allowLinker: true
158173
};
159174

160175
analytics.initialize();
161176
analytics.page();
162-
analytics.deepEqual(toArray(window.ga.q[0]), ['create', settings.trackingId, expectedOpts]);
177+
// some workaround for useGoogleAmpClientId as the name passed to GA needed to change to useAMPclientID
178+
// but the tests expect the option name to == the parameter passed
179+
var expectedOptsOmitAmp = _.omit(expectedOpts,['useGoogleAmpClientId']);
180+
var gaOptsOmitAmp = _.omit(window.ga.q[0][2],'useAMPclientID');
181+
window.ga.q[0][2] = gaOptsOmitAmp;
182+
183+
analytics.deepEqual(toArray(window.ga.q[0]), ['create', settings.trackingId, expectedOptsOmitAmp]);
163184
});
164185

165186
it('should call window.ga.require for optimize if enabled', function() {

0 commit comments

Comments
 (0)