UNPKG

@lonelyplanet/dotcom-core

Version:

This package is meant to house some of our more common UI and shared libs across dotcom applications.

35 lines (34 loc) 1.11 kB
import * as React from "react"; import DataLayer, { reducePropsToState, createDataLayerScript } from "../containers/dataLayer"; import { shallow } from "enzyme"; describe("<DataLayer />", function () { it("should be a component", function () { var wrapper = shallow(React.createElement(DataLayer, { data: { cd1: "custom dimension" } })); var data = DataLayer.peek(); expect(data).toEqual({ cd1: "custom dimension" }); }); it("should combine all calls into one object", function () { var state = reducePropsToState([{ data: { cd1: "foo" }, }, { data: { cd2: "bar", } }]); expect(state).toHaveProperty("cd1"); expect(state).toHaveProperty("cd2"); }); it("should create an initial data layer script", function () { var script = createDataLayerScript({ cd1: "foo", cd2: "bar", }); expect(script).toMatchSnapshot(); }); });