summaryrefslogtreecommitdiffstats
path: root/browser/components/newtab/test/unit/content-src/components/PocketLoggedInCta.test.jsx
blob: 31a5e7be4d7377ad0f84db0961de06a3ddd6da51 (plain)
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
import { combineReducers, createStore } from "redux";
import { INITIAL_STATE, reducers } from "common/Reducers.sys.mjs";
import { mount, shallow } from "enzyme";
import {
  PocketLoggedInCta,
  _PocketLoggedInCta as PocketLoggedInCtaRaw,
} from "content-src/components/PocketLoggedInCta/PocketLoggedInCta";
import { Provider } from "react-redux";
import React from "react";

function mountSectionWithProps(props) {
  const store = createStore(combineReducers(reducers), INITIAL_STATE);
  return mount(
    <Provider store={store}>
      <PocketLoggedInCta {...props} />
    </Provider>
  );
}

describe("<PocketLoggedInCta>", () => {
  it("should render a PocketLoggedInCta element", () => {
    const wrapper = mountSectionWithProps({});
    assert.ok(wrapper.exists());
  });
  it("should render Fluent spans when rendered without props", () => {
    const wrapper = mountSectionWithProps({});

    const message = wrapper.find("span[data-l10n-id]");
    assert.lengthOf(message, 2);
  });
  it("should not render Fluent spans when rendered with props", () => {
    const wrapper = shallow(
      <PocketLoggedInCtaRaw
        Pocket={{
          pocketCta: {
            ctaButton: "button",
            ctaText: "text",
          },
        }}
      />
    );

    const message = wrapper.find("span[data-l10n-id]");
    assert.lengthOf(message, 0);
  });
});