forked from angulartics/angulartics2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsplunk.spec.ts
58 lines (49 loc) · 1.56 KB
/
splunk.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
50
51
52
53
54
55
56
57
58
import {
fakeAsync,
inject,
ComponentFixture,
TestBed,
} from '@angular/core/testing';
import { Angulartics2 } from 'angulartics2';
import { advance, createRoot, RootCmp, TestModule } from '../../test.mocks';
import { Angulartics2Splunk } from './splunk';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
declare var window: any;
describe('Angulartics2Splunk', () => {
let fixture: ComponentFixture<any>;
let sp: any;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [TestModule],
providers: [Angulartics2Splunk],
});
window.sp = sp = {
pageview: jasmine.createSpy('pageview'),
track: jasmine.createSpy('track')
};
const provider: Angulartics2Splunk = TestBed.get(Angulartics2Splunk);
provider.startTracking();
});
it('should track pages',
fakeAsync(inject([Angulartics2, Angulartics2Splunk],
(angulartics2: Angulartics2, angulartics2Splunk: Angulartics2Splunk) => {
fixture = createRoot(RootCmp);
angulartics2.pageTrack.next({ path: '/abc' });
advance(fixture);
expect(sp.pageview).toHaveBeenCalledWith('/abc');
}),
),
);
it('should track events',
fakeAsync(inject([Angulartics2, Angulartics2Splunk],
(angulartics2: Angulartics2, angulartics2Splunk: Angulartics2Splunk) => {
fixture = createRoot(RootCmp);
angulartics2.eventTrack.next({ action: 'do', properties: { category: 'cat' } });
advance(fixture);
expect(sp.track).toHaveBeenCalledWith('do', {
category: 'cat',
});
}),
),
);
});