Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
test(core/seo): check that meta description is inserted on idle
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres authored and Marcos Cáceres committed Aug 16, 2017
1 parent 3791be7 commit 8ae67f4
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions tests/spec/core/seo-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,43 @@ describe("Core — Seo", () => {
it("doesn't insert a meta description element if there is no abstract", async () => {
const ops = {
config: makeBasicConfig(),
body: `
<section id="">
<p>Fail</p>
</section>`,
abstract: "\n",
body: makeDefaultBody(),
};
const doc = await makeRSDoc(ops);
await doc.respecIsReady;
expect(doc.querySelectorAll("meta[name=description]").length).toEqual(0);
await new Promise(resolve => {
const check = () => {
const hasMetaDesc = doc.querySelectorAll("meta[name=description]")
.length;
expect(hasMetaDesc).toEqual(0);
resolve();
};
window.requestIdleCallback ? window.requestIdleCallback(check) : check();
});
});

it("inserts a meta description element after processing", async () => {
it("inserts a meta element for the description after processing", async () => {
const ops = {
config: makeBasicConfig(),
body: `
<section id="abstract">
<p>Pass</p>
<p>Fail</p>
</section>`,
abstract: `<p>
Pass \t
</p>
<p>Fail</p>`,
body: makeDefaultBody(),
};
const doc = await makeRSDoc(ops);
await doc.respecIsReady;
expect(doc.querySelectorAll("meta[name=description]").length).toEqual(1);
const meta = doc.head.querySelector("meta[name=description]");
expect(meta.content).toEqual("Pass");
await new Promise(resolve => {
const check = () => {
const hasMetaDesc = doc.querySelectorAll("meta[name=description]")
.length;
expect(hasMetaDesc).toEqual(1);
const meta = doc.head.querySelector("meta[name=description]");
expect(meta.content).toEqual("Pass");
resolve();
};
window.requestIdleCallback ? window.requestIdleCallback(check) : check();
});
});
});

0 comments on commit 8ae67f4

Please sign in to comment.