@@ -86,7 +85,7 @@ describe("Helmet - Declarative API", () => {
});
});
- it("sets title based on deepest nested component", (done) => {
+ it("sets title based on deepest nested component", done => {
ReactDOM.render(
@@ -106,7 +105,7 @@ describe("Helmet - Declarative API", () => {
});
});
- it("sets title using deepest nested component with a defined title", (done) => {
+ it("sets title using deepest nested component with a defined title", done => {
ReactDOM.render(
@@ -124,11 +123,13 @@ describe("Helmet - Declarative API", () => {
});
});
- it("uses defaultTitle if no title is defined", (done) => {
+ it("uses defaultTitle if no title is defined", done => {
ReactDOM.render(
,
@@ -142,11 +143,13 @@ describe("Helmet - Declarative API", () => {
});
});
- it("uses a titleTemplate if defined", (done) => {
+ it("uses a titleTemplate if defined", done => {
ReactDOM.render(
Test,
@@ -154,16 +157,20 @@ describe("Helmet - Declarative API", () => {
);
requestIdleCallback(() => {
- expect(document.title).to.equal("This is a Test of the titleTemplate feature");
+ expect(document.title).to.equal(
+ "This is a Test of the titleTemplate feature"
+ );
done();
});
});
- it("replaces multiple title strings in titleTemplate", (done) => {
+ it("replaces multiple title strings in titleTemplate", done => {
ReactDOM.render(
Test,
@@ -171,22 +178,28 @@ describe("Helmet - Declarative API", () => {
);
requestIdleCallback(() => {
- expect(document.title).to.equal("This is a Test of the titleTemplate feature. Another Test.");
+ expect(document.title).to.equal(
+ "This is a Test of the titleTemplate feature. Another Test."
+ );
done();
});
});
- it("uses a titleTemplate based on deepest nested component", (done) => {
+ it("uses a titleTemplate based on deepest nested component", done => {
ReactDOM.render(
TestSecond Test
@@ -195,17 +208,21 @@ describe("Helmet - Declarative API", () => {
);
requestIdleCallback(() => {
- expect(document.title).to.equal("A Second Test using nested titleTemplate attributes");
+ expect(document.title).to.equal(
+ "A Second Test using nested titleTemplate attributes"
+ );
done();
});
});
- it("merges deepest component title with nearest upstream titleTemplate", (done) => {
+ it("merges deepest component title with nearest upstream titleTemplate", done => {
ReactDOM.render(
Test
@@ -217,32 +234,34 @@ describe("Helmet - Declarative API", () => {
);
requestIdleCallback(() => {
- expect(document.title).to.equal("This is a Second Test of the titleTemplate feature");
+ expect(document.title).to.equal(
+ "This is a Second Test of the titleTemplate feature"
+ );
done();
});
});
- it("renders dollar characters in a title correctly when titleTemplate present", (done) => {
+ it("renders dollar characters in a title correctly when titleTemplate present", done => {
const dollarTitle = "te$t te$$t te$$$t te$$$$t";
ReactDOM.render(
-
+ {dollarTitle},
container
);
requestIdleCallback(() => {
- expect(document.title).to.equal("This is a te$t te$$t te$$$t te$$$$t");
+ expect(document.title).to.equal(
+ "This is a te$t te$$t te$$$t te$$$$t"
+ );
done();
});
});
- it("does not encode all characters with HTML character entity equivalents", (done) => {
+ it("does not encode all characters with HTML character entity equivalents", done => {
const chineseTitle = "膣膗 鍆錌雔";
ReactDOM.render(
@@ -259,11 +278,9 @@ describe("Helmet - Declarative API", () => {
});
});
- it("page title with prop itemProp", (done) => {
+ it("page title with prop itemProp", done => {
ReactDOM.render(
-
+ Test Title with itemProp,
container
@@ -278,7 +295,7 @@ describe("Helmet - Declarative API", () => {
});
});
- it("retains existing title tag when no title tag is defined", (done) => {
+ it("retains existing title tag when no title tag is defined", done => {
headElement.innerHTML = `Existing Title`;
ReactDOM.render(
@@ -295,7 +312,7 @@ describe("Helmet - Declarative API", () => {
});
});
- it("clears title tag if empty title is defined", (done) => {
+ it("clears title tag if empty title is defined", done => {
ReactDOM.render(
Existing Title
@@ -328,7 +345,7 @@ describe("Helmet - Declarative API", () => {
headElement.innerHTML = `Test Title`;
});
- it("updates title attributes", (done) => {
+ it("updates title attributes", done => {
ReactDOM.render(
@@ -340,13 +357,15 @@ describe("Helmet - Declarative API", () => {
const titleTag = document.getElementsByTagName("title")[0];
expect(titleTag.getAttribute("itemprop")).to.equal("name");
- expect(titleTag.getAttribute(HELMET_ATTRIBUTE)).to.equal("itemprop");
+ expect(titleTag.getAttribute(HELMET_ATTRIBUTE)).to.equal(
+ "itemprop"
+ );
done();
});
});
- it("sets attributes based on the deepest nested component", (done) => {
+ it("sets attributes based on the deepest nested component", done => {
ReactDOM.render(
`);
});
});
@@ -2996,7 +3348,7 @@ describe("Helmet - Declarative API", () => {
);
});
- it("lets you read current state in peek() whether or not a DOM is present", (done) => {
+ it("lets you read current state in peek() whether or not a DOM is present", done => {
ReactDOM.render(
Fancy title
@@ -3014,42 +3366,50 @@ describe("Helmet - Declarative API", () => {
});
});
- it("encodes special characters", (done) => {
+ it("encodes special characters", done => {
ReactDOM.render(
-
+
,
container
);
requestIdleCallback(() => {
- const existingTags = headElement.querySelectorAll(`meta[${HELMET_ATTRIBUTE}]`);
+ const existingTags = headElement.querySelectorAll(
+ `meta[${HELMET_ATTRIBUTE}]`
+ );
const existingTag = existingTags[0];
expect(existingTags).to.not.equal(undefined);
expect(existingTags.length).to.be.equal(1);
- expect(existingTags)
- .to.have.deep.property("[0]")
+ expect(existingTags).to.have.deep
+ .property("[0]")
.that.is.an.instanceof(Element);
expect(existingTag).to.have.property("getAttribute");
- expect(existingTag.getAttribute("name")).to.equal("description");
- expect(existingTag.getAttribute("content")).to.equal("This is \"quoted\" text and & and '.");
- expect(existingTag.outerHTML).to.equal(``);
+ expect(existingTag.getAttribute("name")).to.equal(
+ "description"
+ );
+ expect(existingTag.getAttribute("content")).to.equal(
+ 'This is "quoted" text and & and \'.'
+ );
+ expect(existingTag.outerHTML).to.equal(
+ ``
+ );
done();
});
});
- it("does not change the DOM if it recevies identical props", (done) => {
+ it("does not change the DOM if it recevies identical props", done => {
const spy = sinon.spy();
ReactDOM.render(
-
+
Test Title,
container
@@ -3058,13 +3418,8 @@ describe("Helmet - Declarative API", () => {
requestIdleCallback(() => {
// Re-rendering will pass new props to an already mounted Helmet
ReactDOM.render(
-
-
+
+
Test Title,
container
@@ -3078,13 +3433,16 @@ describe("Helmet - Declarative API", () => {
});
});
- it("does not write the DOM if the client and server are identical", (done) => {
+ it("does not write the DOM if the client and server are identical", done => {
headElement.innerHTML = ``;
const spy = sinon.spy();
ReactDOM.render(
-
+
,
container
);
@@ -3101,7 +3459,7 @@ describe("Helmet - Declarative API", () => {
});
});
- it("only adds new tags and preserves tags when rendering additional Helmet instances", (done) => {
+ it("only adds new tags and preserves tags when rendering additional Helmet instances", done => {
const spy = sinon.spy();
let addedTags;
let removedTags;
@@ -3112,10 +3470,7 @@ describe("Helmet - Declarative API", () => {
rel="stylesheet"
type="text/css"
/>
-
+
,
container
);
@@ -3127,10 +3482,14 @@ describe("Helmet - Declarative API", () => {
expect(addedTags).to.have.property("metaTags");
expect(addedTags.metaTags).to.have.deep.property("[0]");
- expect(addedTags.metaTags[0].outerHTML).to.equal(``);
+ expect(addedTags.metaTags[0].outerHTML).to.equal(
+ ``
+ );
expect(addedTags).to.have.property("linkTags");
expect(addedTags.linkTags).to.have.deep.property("[0]");
- expect(addedTags.linkTags[0].outerHTML).to.equal(``);
+ expect(addedTags.linkTags[0].outerHTML).to.equal(
+ ``
+ );
expect(removedTags).to.be.empty;
// Re-rendering will pass new props to an already mounted Helmet
@@ -3146,10 +3505,7 @@ describe("Helmet - Declarative API", () => {
rel="stylesheet"
type="text/css"
/>
-
+
,
container
);
@@ -3161,13 +3517,19 @@ describe("Helmet - Declarative API", () => {
expect(addedTags).to.have.property("metaTags");
expect(addedTags.metaTags).to.have.deep.property("[0]");
- expect(addedTags.metaTags[0].outerHTML).to.equal(``);
+ expect(addedTags.metaTags[0].outerHTML).to.equal(
+ ``
+ );
expect(addedTags).to.have.property("linkTags");
expect(addedTags.linkTags).to.have.deep.property("[0]");
- expect(addedTags.linkTags[0].outerHTML).to.equal(``);
+ expect(addedTags.linkTags[0].outerHTML).to.equal(
+ ``
+ );
expect(removedTags).to.have.property("metaTags");
expect(removedTags.metaTags).to.have.deep.property("[0]");
- expect(removedTags.metaTags[0].outerHTML).to.equal(``);
+ expect(removedTags.metaTags[0].outerHTML).to.equal(
+ ``
+ );
expect(removedTags).to.not.have.property("linkTags");
done();
@@ -3175,7 +3537,7 @@ describe("Helmet - Declarative API", () => {
});
});
- it("does not accept nested Helmets", (done) => {
+ it("does not accept nested Helmets", done => {
const warn = sinon.stub(console, "warn");
ReactDOM.render(
@@ -3193,7 +3555,9 @@ describe("Helmet - Declarative API", () => {
expect(warn.called).to.be.true;
const [warning] = warn.getCall(0).args;
- expect(warning).to.equal("You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information.");
+ expect(warning).to.equal(
+ "You may be attempting to nest components within each other, which is not allowed. Refer to our API for more information."
+ );
warn.restore();
@@ -3201,7 +3565,7 @@ describe("Helmet - Declarative API", () => {
});
});
- it("warns on invalid elements", (done) => {
+ it("warns on invalid elements", done => {
const warn = sinon.stub(console, "warn");
ReactDOM.render(
@@ -3219,14 +3583,16 @@ describe("Helmet - Declarative API", () => {
expect(warn.called).to.be.true;
const [warning] = warn.getCall(0).args;
- expect(warning).to.equal("Only elements types base, body, head, html, link, meta, noscript, script, style, title are allowed. Helmet does not support rendering
elements. Refer to our API for more information.");
+ expect(warning).to.equal(
+ "Only elements types base, body, head, html, link, meta, noscript, script, style, title are allowed. Helmet does not support rendering
elements. Refer to our API for more information."
+ );
warn.restore();
done();
});
});
- it("warns on invalid self-closing elements", (done) => {
+ it("warns on invalid self-closing elements", done => {
const warn = sinon.stub(console, "warn");
ReactDOM.render(
@@ -3242,7 +3608,9 @@ describe("Helmet - Declarative API", () => {
expect(warn.called).to.be.true;
const [warning] = warn.getCall(0).args;
- expect(warning).to.equal("Only elements types base, body, head, html, link, meta, noscript, script, style, title are allowed. Helmet does not support rendering
elements. Refer to our API for more information.");
+ expect(warning).to.equal(
+ "Only elements types base, body, head, html, link, meta, noscript, script, style, title are allowed. Helmet does not support rendering
elements. Refer to our API for more information."
+ );
warn.restore();
done();
@@ -3250,21 +3618,26 @@ describe("Helmet - Declarative API", () => {
});
it("throws on invalid strings as children", () => {
- const renderInvalid = () => (
+ const renderInvalid = () =>
ReactDOM.render(
Test Title
- {`test`}
+ {`test`}
,
container
- )
- );
+ );
- expect(renderInvalid).to.throw(Error, " elements are self-closing and can not contain children. Refer to our API for more information.");
+ expect(renderInvalid).to.throw(
+ Error,
+ " elements are self-closing and can not contain children. Refer to our API for more information."
+ );
});
it("throws on invalid children", () => {
- const renderInvalid = () => (
+ const renderInvalid = () =>
ReactDOM.render(
Test Title
@@ -3273,13 +3646,15 @@ describe("Helmet - Declarative API", () => {
,
container
- )
- );
+ );
- expect(renderInvalid).to.throw(Error, "Helmet expects a string as a child of ) Refer to our API for more information.");
+ expect(renderInvalid).to.throw(
+ Error,
+ "Helmet expects a string as a child of ) Refer to our API for more information."
+ );
});
- it("handles undefined children", (done) => {
+ it("handles undefined children", done => {
const charSet = undefined;
ReactDOM.render(
@@ -3297,48 +3672,53 @@ describe("Helmet - Declarative API", () => {
});
});
- it("recognizes valid tags regardless of attribute ordering", (done) => {
+ it("recognizes valid tags regardless of attribute ordering", done => {
ReactDOM.render(
-
+
,
container
);
requestIdleCallback(() => {
- const existingTags = headElement.querySelectorAll(`meta[${HELMET_ATTRIBUTE}]`);
+ const existingTags = headElement.querySelectorAll(
+ `meta[${HELMET_ATTRIBUTE}]`
+ );
const existingTag = existingTags[0];
expect(existingTags).to.not.equal(undefined);
expect(existingTags.length).to.be.equal(1);
- expect(existingTags)
- .to.have.deep.property("[0]")
+ expect(existingTags).to.have.deep
+ .property("[0]")
.that.is.an.instanceof(Element);
expect(existingTag).to.have.property("getAttribute");
- expect(existingTag.getAttribute("name")).to.equal("description");
- expect(existingTag.getAttribute("content")).to.equal("Test Description");
- expect(existingTag.outerHTML).to.equal(``);
+ expect(existingTag.getAttribute("name")).to.equal(
+ "description"
+ );
+ expect(existingTag.getAttribute("content")).to.equal(
+ "Test Description"
+ );
+ expect(existingTag.outerHTML).to.equal(
+ ``
+ );
done();
});
});
- it("requestIdleCallback works as expected", (done) => {
- requestIdleCallback((cb) => {
+ it("requestIdleCallback works as expected", done => {
+ requestIdleCallback(cb => {
expect(cb).to.exist;
- expect(cb)
- .to.have.property("didTimeout")
+ expect(cb).to.have
+ .property("didTimeout")
.that.is.a("boolean")
.that.equals(false);
- expect(cb)
- .to.have.property("timeRemaining")
+ expect(cb).to.have
+ .property("timeRemaining")
.that.is.a("function");
const time = cb.timeRemaining();
diff --git a/test/HelmetTest.js b/test/HelmetTest.js
index d3b82874..43d02ff2 100644
--- a/test/HelmetTest.js
+++ b/test/HelmetTest.js
@@ -15,7 +15,8 @@ describe("Helmet", () => {
const container = document.createElement("div");
beforeEach(() => {
- headElement = headElement || document.head || document.querySelector("head");
+ headElement =
+ headElement || document.head || document.querySelector("head");
// resets DOM after each run
headElement.innerHTML = "";
@@ -27,12 +28,9 @@ describe("Helmet", () => {
describe("api", () => {
describe("title", () => {
- it("updates page title", (done) => {
+ it("updates page title", done => {
ReactDOM.render(
- ,
+ ,
container
);
@@ -43,7 +41,7 @@ describe("Helmet", () => {
});
});
- it("updates page title with multiple children", (done) => {
+ it("updates page title with multiple children", done => {
ReactDOM.render(
@@ -60,7 +58,7 @@ describe("Helmet", () => {
});
});
- it("sets title based on deepest nested component", (done) => {
+ it("sets title based on deepest nested component", done => {
ReactDOM.render(
@@ -76,7 +74,7 @@ describe("Helmet", () => {
});
});
- it("sets title using deepest nested component with a defined title", (done) => {
+ it("sets title using deepest nested component with a defined title", done => {
ReactDOM.render(
@@ -92,12 +90,14 @@ describe("Helmet", () => {
});
});
- it("uses defaultTitle if no title is defined", (done) => {
+ it("uses defaultTitle if no title is defined", done => {
ReactDOM.render(
,
container
);
@@ -109,67 +109,83 @@ describe("Helmet", () => {
});
});
- it("uses a titleTemplate if defined", (done) => {
+ it("uses a titleTemplate if defined", done => {
ReactDOM.render(
,
container
);
requestIdleCallback(() => {
- expect(document.title).to.equal("This is a Test of the titleTemplate feature");
+ expect(document.title).to.equal(
+ "This is a Test of the titleTemplate feature"
+ );
done();
});
});
- it("replaces multiple title strings in titleTemplate", (done) => {
+ it("replaces multiple title strings in titleTemplate", done => {
ReactDOM.render(
,
container
);
requestIdleCallback(() => {
- expect(document.title).to.equal("This is a Test of the titleTemplate feature. Another Test.");
+ expect(document.title).to.equal(
+ "This is a Test of the titleTemplate feature. Another Test."
+ );
done();
});
});
- it("uses a titleTemplate based on deepest nested component", (done) => {
+ it("uses a titleTemplate based on deepest nested component", done => {
ReactDOM.render(
,
container
);
requestIdleCallback(() => {
- expect(document.title).to.equal("A Second Test using nested titleTemplate attributes");
+ expect(document.title).to.equal(
+ "A Second Test using nested titleTemplate attributes"
+ );
done();
});
});
- it("merges deepest component title with nearest upstream titleTemplate", (done) => {
+ it("merges deepest component title with nearest upstream titleTemplate", done => {
ReactDOM.render(
,
@@ -177,30 +193,35 @@ describe("Helmet", () => {
);
requestIdleCallback(() => {
- expect(document.title).to.equal("This is a Second Test of the titleTemplate feature");
+ expect(document.title).to.equal(
+ "This is a Second Test of the titleTemplate feature"
+ );
done();
});
});
- it("renders dollar characters in a title correctly when titleTemplate present", (done) => {
+ it("renders dollar characters in a title correctly when titleTemplate present", done => {
const dollarTitle = "te$t te$$t te$$$t te$$$$t";
ReactDOM.render(
- ,
container
);
requestIdleCallback(() => {
- expect(document.title).to.equal("This is a te$t te$$t te$$$t te$$$$t");
+ expect(document.title).to.equal(
+ "This is a te$t te$$t te$$$t te$$$$t"
+ );
done();
});
});
- it("does not encode all characters with HTML character entity equivalents", (done) => {
+ it("does not encode all characters with HTML character entity equivalents", done => {
const chineseTitle = "膣膗 鍆錌雔";
ReactDOM.render(
@@ -217,7 +238,7 @@ describe("Helmet", () => {
});
});
- it("page title with prop itemprop", (done) => {
+ it("page title with prop itemprop", done => {
ReactDOM.render(
{
headElement.innerHTML = `Test Title`;
});
- it("update title attributes", (done) => {
+ it("update title attributes", done => {
ReactDOM.render(
{
requestIdleCallback(() => {
const titleTag = document.getElementsByTagName("title")[0];
expect(titleTag.getAttribute("itemprop")).to.equal("name");
- expect(titleTag.getAttribute(HELMET_ATTRIBUTE)).to.equal("itemprop");
+ expect(titleTag.getAttribute(HELMET_ATTRIBUTE)).to.equal(
+ "itemprop"
+ );
done();
});
});
- it("sets attributes based on the deepest nested component", (done) => {
+ it("sets attributes based on the deepest nested component", done => {
ReactDOM.render(