forked from snowplow/snowplow-javascript-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponents.test.ts
More file actions
43 lines (38 loc) · 1.19 KB
/
Copy pathcomponents.test.ts
File metadata and controls
43 lines (38 loc) · 1.19 KB
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
import { baseComponentGenerator } from '../src/components';
import { Entities } from '../src/schemata';
import { Configuration } from '../src/configuration';
describe('component detection', () => {
let container: HTMLElement;
const config: Configuration = {
name: 'template',
selector: 'body',
shadowOnly: false,
component: true,
context: () => [],
trackers: [],
create: { when: 'never' },
destroy: { when: 'never' },
expose: { when: 'never', minPercentage: 0, boundaryPixels: 0, minSize: 0, minTimeMillis: 0 },
obscure: { when: 'never' },
state: 0,
details: [],
contents: [],
includeStats: [],
};
beforeAll(() => {
container = document.createElement('div');
document.body.appendChild(container);
});
it('no-ops without target element', () => {
expect(baseComponentGenerator(true, [config])).toBeNull();
});
it('finds components from child target', () => {
expect(baseComponentGenerator(false, [config], container)).toEqual({
schema: Entities.COMPONENT_PARENTS,
data: {
component_list: [config.name],
},
});
expect(baseComponentGenerator(true, [config], container)).toHaveLength(2);
});
});