Total Complexity | 3 |
Complexity/F | 1 |
Lines of Code | 28 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | const f = require('./index'); |
||
2 | |||
3 | test('check referrer', () => { |
||
4 | let d = getTestDocument(); |
||
5 | d.referrer = 'google'; |
||
6 | |||
7 | const lastClick = f(d); |
||
8 | lastClick.check(); |
||
9 | expect(lastClick.getLastClick()).toBe('google'); |
||
10 | }); |
||
11 | |||
12 | test('check location', () => { |
||
13 | let d = getTestDocument(); |
||
14 | d.location.search = '?utm_source=example.com'; |
||
15 | |||
16 | const lastClick = f(d); |
||
17 | lastClick.check(); |
||
18 | expect(lastClick.getLastClick()).toBe('example.com'); |
||
19 | }); |
||
20 | |||
21 | function getTestDocument() { |
||
22 | return { |
||
23 | referrer: '', |
||
24 | location: { |
||
25 | search: '' |
||
26 | } |
||
27 | }; |
||
28 | } |