From cfe721c9d23fa9cd80cd333f3bc15d5c4ac1f77b Mon Sep 17 00:00:00 2001 From: Christoph Burgmer Date: Fri, 2 May 2014 21:40:54 +0200 Subject: [PATCH] Document issue #2. Refactor fixture helper --- test/specs/InlineScriptSpec.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/test/specs/InlineScriptSpec.js b/test/specs/InlineScriptSpec.js index 4410c35..3f839f9 100644 --- a/test/specs/InlineScriptSpec.js +++ b/test/specs/InlineScriptSpec.js @@ -30,19 +30,21 @@ describe("JS inline", function () { }; var anExternalScript = function () { - return anExternalScriptWith("url/some.js", "var b = 1;"); + return anExternalScriptWith("var b = 1;", "url/some.js"); }; var anotherExternalScript = function () { - var script = anExternalScriptWith("url/someOther.js", "function something() {}"); + var script = anExternalScriptWith("function something() {}", "url/someOther.js"); script.type = "text/javascript"; script.id = "myScript"; return script; }; - var anExternalScriptWith = function (url, content) { + var anExternalScriptWith = function (content, url) { var externalScript = window.document.createElement("script"); + url = url || 'some/url.js'; + externalScript.src = url; mockAjaxUrl(url, content); @@ -133,11 +135,7 @@ describe("JS inline", function () { }); it("should correctly quote closing HTML tags in the script", function (done) { - var script = window.document.createElement("script"); - script.src = "some_url.js"; - - mockAjaxUrl("some_url.js", 'var closingScriptTag = "";'); - doc.head.appendChild(script); + doc.head.appendChild(anExternalScriptWith('var closingScriptTag = "";')); inlineScript.inline(doc, {}).then(function () { expect(doc.head.getElementsByTagName("script")[0].textContent).toEqual('var closingScriptTag = "<\\/script>";'); @@ -146,6 +144,16 @@ describe("JS inline", function () { }); }); + xit("should not quote a regex", function (done) { + doc.head.appendChild(anExternalScriptWith("/