1 | import * as React from "react";
|
2 | import DataLayer, { reducePropsToState, createDataLayerScript } from "../containers/dataLayer";
|
3 | import { shallow } from "enzyme";
|
4 |
|
5 | describe("<DataLayer />", () => {
|
6 | it("should be a component", () => {
|
7 | const wrapper = shallow(<DataLayer
|
8 | data={{
|
9 | cd1: "custom dimension"
|
10 | }}
|
11 | />);
|
12 |
|
13 | const data = DataLayer.peek();
|
14 | expect(data).toEqual({
|
15 | cd1: "custom dimension"
|
16 | });
|
17 | });
|
18 |
|
19 | it("should combine all calls into one object", () => {
|
20 | const state = reducePropsToState([{
|
21 | data: {
|
22 | cd1: "foo"
|
23 | },
|
24 | }, {
|
25 | data: {
|
26 | cd2: "bar",
|
27 | }
|
28 | }])
|
29 |
|
30 | expect(state).toHaveProperty("cd1");
|
31 | expect(state).toHaveProperty("cd2");
|
32 | });
|
33 |
|
34 | it("should create an initial data layer script", () => {
|
35 | const script = createDataLayerScript({
|
36 | cd1: "foo",
|
37 | cd2: "bar",
|
38 | });
|
39 |
|
40 | expect(script).toMatchSnapshot();
|
41 | });
|
42 | });
|