summaryrefslogtreecommitdiffstats
path: root/browser/components/newtab/test/unit/content-src/components/DiscoveryStreamComponents/Highlights.test.jsx
blob: d8c16d8e712f4ad7eb08c795921567d6e95a5978 (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
import { combineReducers, createStore } from "redux";
import { INITIAL_STATE, reducers } from "common/Reducers.sys.mjs";
import { Highlights } from "content-src/components/DiscoveryStreamComponents/Highlights/Highlights";
import { mount } from "enzyme";
import { Provider } from "react-redux";
import React from "react";

describe("Discovery Stream <Highlights>", () => {
  let wrapper;

  afterEach(() => {
    wrapper.unmount();
  });

  it("should render nothing with no highlights data", () => {
    const store = createStore(combineReducers(reducers), { ...INITIAL_STATE });

    wrapper = mount(
      <Provider store={store}>
        <Highlights />
      </Provider>
    );

    assert.ok(wrapper.isEmptyRender());
  });

  it("should render highlights", () => {
    const store = createStore(combineReducers(reducers), {
      ...INITIAL_STATE,
      Sections: [{ id: "highlights", enabled: true }],
    });

    wrapper = mount(
      <Provider store={store}>
        <Highlights />
      </Provider>
    );

    assert.lengthOf(wrapper.find(".ds-highlights"), 1);
  });
});