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
51
52
53
54
55
56
57
|
import { DSMessage } from "content-src/components/DiscoveryStreamComponents/DSMessage/DSMessage";
import React from "react";
import { SafeAnchor } from "content-src/components/DiscoveryStreamComponents/SafeAnchor/SafeAnchor";
import { FluentOrText } from "content-src/components/FluentOrText/FluentOrText";
import { mount } from "enzyme";
describe("<DSMessage>", () => {
let wrapper;
beforeEach(() => {
wrapper = mount(<DSMessage />);
});
it("should render", () => {
assert.ok(wrapper.exists());
assert.ok(wrapper.find(".ds-message").exists());
});
it("should render an icon", () => {
wrapper.setProps({ icon: "foo" });
assert.ok(wrapper.find(".glyph").exists());
assert.propertyVal(
wrapper.find(".glyph").props().style,
"backgroundImage",
`url(foo)`
);
});
it("should render a title", () => {
wrapper.setProps({ title: "foo" });
assert.ok(wrapper.find(".title-text").exists());
assert.equal(wrapper.find(".title-text").text(), "foo");
});
it("should render a SafeAnchor", () => {
wrapper.setProps({ link_text: "foo", link_url: "https://foo.com" });
assert.equal(wrapper.find(".title").children().at(0).type(), SafeAnchor);
});
it("should render a FluentOrText", () => {
wrapper.setProps({
link_text: "link_text",
title: "title",
link_url: "https://link_url.com",
});
assert.equal(
wrapper.find(".title-text").children().at(0).type(),
FluentOrText
);
assert.equal(wrapper.find(".link a").children().at(0).type(), FluentOrText);
});
});
|