Skip to content

Commit

Permalink
Additional htmlAttributes unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
cwelch5 committed Dec 29, 2016
2 parents e6ec816 + c509eb2 commit 9af19cd
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions src/test/HelmetTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,67 @@ describe("Helmet", () => {
expect(htmlTag.getAttribute(HELMET_ATTRIBUTE)).to.equal(null);
});

it("updates with multiple additions and removals - overwrite and new", () => {
ReactDOM.render(
<Helmet
htmlAttributes={{
"lang": "en",
"amp": undefined
}}
/>,
container
);

ReactDOM.render(
<Helmet
htmlAttributes={{
"lang": "ja",
"id": "html-tag",
"title": "html tag"
}}
/>,
container
);

const htmlTag = document.getElementsByTagName("html")[0];

expect(htmlTag.getAttribute("amp")).to.equal(null);
expect(htmlTag.getAttribute("lang")).to.equal("ja");
expect(htmlTag.getAttribute("id")).to.equal("html-tag");
expect(htmlTag.getAttribute("title")).to.equal("html tag");
expect(htmlTag.getAttribute(HELMET_ATTRIBUTE)).to.equal("lang,amp,id,title");
});

it("updates with multiple additions and removals - all new", () => {
ReactDOM.render(
<Helmet
htmlAttributes={{
"lang": "en",
"amp": undefined
}}
/>,
container
);

ReactDOM.render(
<Helmet
htmlAttributes={{
"id": "html-tag",
"title": "html tag"
}}
/>,
container
);

const htmlTag = document.getElementsByTagName("html")[0];

expect(htmlTag.getAttribute("amp")).to.equal(null);
expect(htmlTag.getAttribute("lang")).to.equal(null);
expect(htmlTag.getAttribute("id")).to.equal("html-tag");
expect(htmlTag.getAttribute("title")).to.equal("html tag");
expect(htmlTag.getAttribute(HELMET_ATTRIBUTE)).to.equal("lang,amp,id,title");
});

context("initialized outside of helmet", () => {
before(() => {
const htmlTag = document.getElementsByTagName("html")[0];
Expand Down

0 comments on commit 9af19cd

Please sign in to comment.