1import { 2 Navigation, 3 Topic, 4} from "content-src/components/DiscoveryStreamComponents/Navigation/Navigation"; 5import React from "react"; 6import { SafeAnchor } from "content-src/components/DiscoveryStreamComponents/SafeAnchor/SafeAnchor"; 7import { FluentOrText } from "content-src/components/FluentOrText/FluentOrText"; 8import { shallow, mount } from "enzyme"; 9 10describe("<Navigation>", () => { 11 let wrapper; 12 13 beforeEach(() => { 14 wrapper = mount(<Navigation header={{}} />); 15 }); 16 17 it("should render", () => { 18 assert.ok(wrapper.exists()); 19 }); 20 21 it("should render a title", () => { 22 wrapper.setProps({ header: { title: "Foo" } }); 23 24 assert.equal(wrapper.find(".ds-header").text(), "Foo"); 25 }); 26 27 it("should render a FluentOrText", () => { 28 wrapper.setProps({ header: { title: "Foo" } }); 29 30 assert.equal( 31 wrapper 32 .find(".ds-navigation") 33 .children() 34 .at(0) 35 .type(), 36 FluentOrText 37 ); 38 }); 39 40 it("should render 2 Topics", () => { 41 wrapper.setProps({ 42 links: [ 43 { url: "https://foo.com", name: "foo" }, 44 { url: "https://bar.com", name: "bar" }, 45 ], 46 }); 47 48 assert.lengthOf(wrapper.find("ul").children(), 2); 49 }); 50}); 51 52describe("<Topic>", () => { 53 let wrapper; 54 55 beforeEach(() => { 56 wrapper = shallow(<Topic url="https://foo.com" name="foo" />); 57 }); 58 59 it("should render", () => { 60 assert.ok(wrapper.exists()); 61 assert.equal(wrapper.type(), SafeAnchor); 62 }); 63}); 64