summaryrefslogtreecommitdiffstats
path: root/browser/components/newtab/test/unit/content-src/components/Topics.test.jsx
blob: 91d15c5d4e0d6975e8b75d22e2702f15c9eeffb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { Topic, Topics } from "content-src/components/Topics/Topics";
import React from "react";
import { shallow } from "enzyme";

describe("<Topics>", () => {
  it("should render a Topics element", () => {
    const wrapper = shallow(<Topics topics={[]} />);
    assert.ok(wrapper.exists());
  });
  it("should render a Topic element for each topic with the right url", () => {
    const data = [
      { name: "topic1", url: "https://topic1.com" },
      { name: "topic2", url: "https://topic2.com" },
    ];

    const wrapper = shallow(<Topics topics={data} />);

    const topics = wrapper.find(Topic);
    assert.lengthOf(topics, 2);
    topics.forEach((topic, i) => assert.equal(topic.props().url, data[i].url));
  });
});