Skip to content

Commit 5ea2989

Browse files
committed
two more tests.
1 parent 6e63d10 commit 5ea2989

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/analytics/src/helpers.test.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,18 +416,27 @@ describe('Gtag wrapping functions', () => {
416416
'gtag'
417417
);
418418
window['dataLayer'] = [];
419-
(window['gtag'] as Gtag)(GtagCommand.CONFIG, fakeMeasurementId, {
419+
const eventObject = {
420420
'language': 'en'
421-
});
421+
};
422+
(window['gtag'] as Gtag)(
423+
GtagCommand.CONFIG,
424+
fakeMeasurementId,
425+
eventObject
426+
);
422427
expect((window['dataLayer'] as DataLayer).length).to.equal(0);
423428

424429
initPromise1.resolve(fakeMeasurementId);
425430
await promiseAllSettled(fakeDynamicConfigPromises); // Resolves dynamic config fetches.
426431
expect((window['dataLayer'] as DataLayer).length).to.equal(0);
427432

428433
await Promise.all([initPromise1]); // Wait for resolution of Promise.all()
429-
console.log('DEDB datalayer:', window['dataLayer']);
430-
expect((window['dataLayer'] as DataLayer).length).to.equal(1);
434+
const dataLayer = window['dataLayer'] as DataLayer;
435+
expect(dataLayer.length).to.equal(1);
436+
const data = dataLayer[0];
437+
expect(data['0']).to.equal('config');
438+
expect(data['1']).to.equal(fakeMeasurementId);
439+
expect(data['2']).to.equal(eventObject);
431440
});
432441

433442
it('new window.gtag function does not wait when sending "config" calls if there are no pending initialization promises', async () => {

0 commit comments

Comments
 (0)