From c02f8b528c3d01427137d8091f25ce3dc003d4af Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Thu, 20 Jul 2017 13:29:10 +1000 Subject: [PATCH] test(core/link-to-dfn-spec): URL encode fragments --- tests/spec/core/link-to-dfn-spec.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/spec/core/link-to-dfn-spec.js b/tests/spec/core/link-to-dfn-spec.js index 4dd4023dd0..67f13bb335 100644 --- a/tests/spec/core/link-to-dfn-spec.js +++ b/tests/spec/core/link-to-dfn-spec.js @@ -4,6 +4,24 @@ describe("Core — Link to definitions", function() { flushIframes(); done(); }); + it("URL-encodes fragment components", done => { + const bodyText = ` + +

Test section

+

[[\\test]][[\\test]] + `; + 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 = `