DSMessage.test.jsx (1591B)
1 import { DSMessage } from "content-src/components/DiscoveryStreamComponents/DSMessage/DSMessage"; 2 import React from "react"; 3 import { SafeAnchor } from "content-src/components/DiscoveryStreamComponents/SafeAnchor/SafeAnchor"; 4 import { FluentOrText } from "content-src/components/FluentOrText/FluentOrText"; 5 import { mount } from "enzyme"; 6 7 describe("<DSMessage>", () => { 8 let wrapper; 9 10 beforeEach(() => { 11 wrapper = mount(<DSMessage />); 12 }); 13 14 it("should render", () => { 15 assert.ok(wrapper.exists()); 16 assert.ok(wrapper.find(".ds-message").exists()); 17 }); 18 19 it("should render an icon", () => { 20 wrapper.setProps({ icon: "foo" }); 21 22 assert.ok(wrapper.find(".glyph").exists()); 23 assert.propertyVal( 24 wrapper.find(".glyph").props().style, 25 "backgroundImage", 26 `url(foo)` 27 ); 28 }); 29 30 it("should render a title", () => { 31 wrapper.setProps({ title: "foo" }); 32 33 assert.ok(wrapper.find(".title-text").exists()); 34 assert.equal(wrapper.find(".title-text").text(), "foo"); 35 }); 36 37 it("should render a SafeAnchor", () => { 38 wrapper.setProps({ link_text: "foo", link_url: "https://foo.com" }); 39 40 assert.equal(wrapper.find(".title").children().at(0).type(), SafeAnchor); 41 }); 42 43 it("should render a FluentOrText", () => { 44 wrapper.setProps({ 45 link_text: "link_text", 46 title: "title", 47 link_url: "https://link_url.com", 48 }); 49 50 assert.equal( 51 wrapper.find(".title-text").children().at(0).type(), 52 FluentOrText 53 ); 54 55 assert.equal(wrapper.find(".link a").children().at(0).type(), FluentOrText); 56 }); 57 });