summaryrefslogtreecommitdiffstats
path: root/browser/components/newtab/test/unit/content-src/components/DiscoveryStreamComponents/DSPrivacyModal.test.jsx
blob: b4b743c7ff07fb0707f222083e7b8ed3328a0b01 (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
47
48
49
50
import { DSPrivacyModal } from "content-src/components/DiscoveryStreamComponents/DSPrivacyModal/DSPrivacyModal";
import { shallow, mount } from "enzyme";
import { actionCreators as ac } from "common/Actions.sys.mjs";
import React from "react";

describe("Discovery Stream <DSPrivacyModal>", () => {
  let sandbox;
  let dispatch;
  let wrapper;
  beforeEach(() => {
    sandbox = sinon.createSandbox();
    dispatch = sandbox.stub();
    wrapper = shallow(<DSPrivacyModal dispatch={dispatch} />);
  });

  afterEach(() => {
    sandbox.restore();
  });

  it("should contain a privacy notice", () => {
    const modal = mount(<DSPrivacyModal />);
    const child = modal.find(".privacy-notice");

    assert.lengthOf(child, 1);
  });

  it("should call dispatch when modal is closed", () => {
    wrapper.instance().closeModal();
    assert.calledOnce(dispatch);
  });

  it("should call dispatch with the correct events for onLearnLinkClick", () => {
    wrapper.instance().onLearnLinkClick();

    assert.calledOnce(dispatch);
    assert.calledWith(
      dispatch,
      ac.DiscoveryStreamUserEvent({
        event: "CLICK_PRIVACY_INFO",
        source: "DS_PRIVACY_MODAL",
      })
    );
  });

  it("should call dispatch with the correct events for onManageLinkClick", () => {
    wrapper.instance().onManageLinkClick();

    assert.calledOnce(dispatch);
  });
});