Skip to content

Commit

Permalink
test(data-cite-spec): data-cite-frag + cite shorthand
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres committed Jan 8, 2017
1 parent 6f06988 commit d004f45
Showing 1 changed file with 62 additions and 1 deletion.
63 changes: 62 additions & 1 deletion tests/spec/core/data-cite-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,65 @@ describe("Core — data-cite attribute", () => {
.toEqual("normative-references");
}).then(done);
});
});
it("adds the fragment identifier to the link", done => {
const ops = {
config: makeBasicConfig(),
body: makeDefaultBody() + `
<section>
<p id="t1"><a
data-cite="!WHATWG-HTML#test">inline link</a></p>
</section>
`,
};
makeRSDoc(ops).then(doc => {
const a = doc.querySelector("#t1 > a");
expect(a.textContent).toEqual("inline link");
expect(a.href).toEqual("https://html.spec.whatwg.org/multipage/#test");
expect(a.hasAttribute("data-cite")).toEqual(false);
expect(doc.querySelector("#bib-WHATWG-HTML").closest("section").id)
.toEqual("normative-references");
}).then(done);
});
describe("data-cite-frag", () => {
it("adds the fragment identifier to the link", done => {
const ops = {
config: makeBasicConfig(),
body: makeDefaultBody() + `
<section>
<p id="t1"><a
data-cite="WHATWG-HTML"
data-cite-frag="pass">inline link</a></p>
</section>
`,
};
makeRSDoc(ops).then(doc => {
const a = doc.querySelector("#t1 > a");
expect(a.textContent).toEqual("inline link");
expect(a.href).toEqual("https://html.spec.whatwg.org/multipage/#pass");
expect(a.hasAttribute("data-cite")).toEqual(false);
expect(doc.querySelector("#bib-WHATWG-HTML").closest("section").id)
.toEqual("informative-references");
}).then(done);
});
it("cited fragments are overridden by cite-frag", done => {
const ops = {
config: makeBasicConfig(),
body: makeDefaultBody() + `
<section>
<p id="t1"><a
data-cite="!WHATWG-HTML#fail"
data-cite-frag="pass">inline link</a></p>
</section>
`,
};
makeRSDoc(ops).then(doc => {
const a = doc.querySelector("#t1 > a");
expect(a.textContent).toEqual("inline link");
expect(a.href).toEqual("https://html.spec.whatwg.org/multipage/#pass");
expect(a.hasAttribute("data-cite")).toEqual(false);
expect(doc.querySelector("#bib-WHATWG-HTML").closest("section").id)
.toEqual("normative-references");
}).then(done);
});
});
});

0 comments on commit d004f45

Please sign in to comment.