forked from angulartics/angulartics2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ga-enhanced-ecom.spec.ts
49 lines (41 loc) · 1.81 KB
/
ga-enhanced-ecom.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { fakeAsync, inject, TestBed } from '@angular/core/testing';
import { TestModule } from '../../test.mocks';
import { Angulartics2GoogleAnalyticsEnhancedEcommerce } from './ga-enhanced-ecom';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
declare var window: any;
describe('Angulartics2GoogleAnalyticsEnhancedEcommerce', () => {
let ga: any;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [TestModule],
providers: [
Angulartics2GoogleAnalyticsEnhancedEcommerce,
],
});
window.ga = ga = jasmine.createSpy('ga');
});
it('should add ec impression',
fakeAsync(inject([Angulartics2GoogleAnalyticsEnhancedEcommerce],
(angulartics2GoogleAnalyticsEnhancedEcommerce: Angulartics2GoogleAnalyticsEnhancedEcommerce) => {
angulartics2GoogleAnalyticsEnhancedEcommerce.ecAddImpression({ id: 'this is id' });
expect(ga).toHaveBeenCalledWith('ec:addImpression', { id: 'this is id' });
}),
),
);
it('should add ec product',
fakeAsync(inject([Angulartics2GoogleAnalyticsEnhancedEcommerce],
(angulartics2GoogleAnalyticsEnhancedEcommerce: Angulartics2GoogleAnalyticsEnhancedEcommerce) => {
angulartics2GoogleAnalyticsEnhancedEcommerce.ecAddProduct({ id: 'this is id', name: 'alexander' });
expect(ga).toHaveBeenCalledWith('ec:addProduct', { id: 'this is id', name: 'alexander' });
}),
),
);
it('should set ec action',
fakeAsync(inject([Angulartics2GoogleAnalyticsEnhancedEcommerce],
(angulartics2GoogleAnalyticsEnhancedEcommerce: Angulartics2GoogleAnalyticsEnhancedEcommerce) => {
angulartics2GoogleAnalyticsEnhancedEcommerce.ecSetAction('add', { id: 'this is some kind of id' });
expect(ga).toHaveBeenCalledWith('ec:setAction', 'add', { id: 'this is some kind of id' });
}),
),
);
});