blob: 57f7e5526c0db9d046e91a28c21317db3e812049 (
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
42
43
44
45
46
47
48
|
import { Localized } from "content-src/components/MSLocalized";
import React from "react";
import { shallow } from "enzyme";
describe("<MSLocalized>", () => {
it("should render span with no children", () => {
const shallowWrapper = shallow(<Localized text="test" />);
assert.ok(shallowWrapper.find("span").exists());
assert.equal(shallowWrapper.text(), "test");
});
it("should render span when using string_id with no children", () => {
const shallowWrapper = shallow(
<Localized text={{ string_id: "test_id" }} />
);
assert.ok(shallowWrapper.find("span[data-l10n-id='test_id']").exists());
});
it("should render text inside child", () => {
const shallowWrapper = shallow(
<Localized text="test">
<div />
</Localized>
);
assert.ok(shallowWrapper.find("div").text(), "test");
});
it("should use l10n id on child", () => {
const shallowWrapper = shallow(
<Localized text={{ string_id: "test_id" }}>
<div />
</Localized>
);
assert.ok(shallowWrapper.find("div[data-l10n-id='test_id']").exists());
});
it("should keep original children", () => {
const shallowWrapper = shallow(
<Localized text={{ string_id: "test_id" }}>
<h1>
<span data-l10n-name="test" />
</h1>
</Localized>
);
assert.ok(shallowWrapper.find("span[data-l10n-name='test']").exists());
});
});
|