Skip to content

Commit

Permalink
test(core/link-to-dfn-spec): URL encode fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres authored and Marcos Cáceres committed Jul 20, 2017
1 parent 135b877 commit c02f8b5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/spec/core/link-to-dfn-spec.js
Expand Up @@ -4,6 +4,24 @@ describe("Core — Link to definitions", function() {
flushIframes();
done();
});
it("URL-encodes fragment components", done => {
const bodyText = `
<section">
<h2>Test section</h2>
<p><dfn>[[\\test]]</dfn><a id="testAnchor">[[\\test]]</a>
</section>`;
const ops = {
config: makeBasicConfig(),
body: makeDefaultBody() + bodyText,
};
makeRSDoc(ops, doc => {
const a = doc.body.querySelector("#testAnchor");
expect(a).toBeTruthy();
expect(a.hash).toEqual("#dfn-x%5B%5Btest%5D%5D");
const decodedHash = decodeURIComponent(a.hash);
expect(doc.getElementById(decodedHash.slice(1))).toBeTruthy();
}).then(done);
});
it("links to IDL definitions and wraps in code if needed", function(done) {
const bodyText = `
<section data-link-for="Request">
Expand Down

0 comments on commit c02f8b5

Please sign in to comment.