From 5523261ac5f5384b77a14728b1645432664642fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20C=C3=A1ceres?= Date: Mon, 8 May 2017 13:38:04 +1000 Subject: [PATCH] chore: run prettier over all js files (#1201) --- js/core/beautify-options.js | 18 +- js/core/issues-notes.js | 111 +- js/core/link-to-dfn.js | 232 +-- js/core/ui.js | 122 +- js/deps/highlight.js | 1657 +++++++++-------- js/github.js | 87 +- js/profile-w3c-common.js | 25 +- js/shortcut.js | 438 ++--- js/tmpl.js | 27 +- js/ui/about-respec.js | 40 +- js/ui/dfn-list.js | 32 +- js/ui/save-html.js | 569 +++--- js/ui/search-specref.js | 156 +- package.json | 2 +- src/core/aria.js | 22 +- src/core/best-practices.js | 5 +- src/core/biblio-db.js | 53 +- src/core/biblio.js | 57 +- src/core/contrib.js | 84 +- src/core/data-cite.js | 30 +- src/core/data-include.js | 53 +- src/core/data-transform.js | 10 +- src/core/dfn.js | 55 +- src/core/examples.js | 19 +- src/core/figures.js | 55 +- src/core/fix-headers.js | 5 +- src/core/highlight.js | 14 +- src/core/include-config.js | 40 +- src/core/inlines.js | 75 +- src/core/jquery-enhanced.js | 54 +- src/core/l10n.js | 12 +- src/core/markdown.js | 24 +- src/core/post-process.js | 34 +- src/core/pre-process.js | 28 +- src/core/pubsubhub.js | 7 +- src/core/rdfa.js | 4 +- src/core/remove-respec.js | 10 +- src/core/requirements.js | 4 +- src/core/structure.js | 43 +- src/core/utils.js | 118 +- src/core/webidl-clipboard.js | 17 +- src/core/webidl-index.js | 15 +- src/core/webidl.js | 370 ++-- src/core/worker.js | 4 +- src/w3c/abstract.js | 3 +- src/w3c/aria.js | 34 +- src/w3c/headers.js | 348 +++- src/w3c/l10n.js | 10 +- src/w3c/linter.js | 48 +- src/w3c/permalinks.js | 22 +- src/w3c/rfc2119.js | 9 +- src/w3c/seo.js | 21 +- src/w3c/style.js | 11 +- tests/spec/SpecHelper.js | 52 +- tests/spec/core/best-practices-spec.js | 4 +- tests/spec/core/biblio-db-spec.js | 316 ++-- tests/spec/core/biblio-spec.js | 42 +- tests/spec/core/data-cite-spec.js | 192 +- tests/spec/core/data-include-spec.js | 24 +- tests/spec/core/default-root-attr-spec.js | 4 +- tests/spec/core/dfn-spec.js | 36 +- tests/spec/core/figures-spec.js | 6 +- tests/spec/core/highlight-spec.js | 16 +- tests/spec/core/id-headers-spec.js | 3 +- tests/spec/core/include-config-spec.js | 8 +- tests/spec/core/informative-spec.js | 4 +- tests/spec/core/inlines-spec.js | 20 +- tests/spec/core/issues-notes-spec.js | 214 ++- tests/spec/core/jquery-enhanced-spec.js | 42 +- tests/spec/core/markdown-spec.js | 73 +- .../spec/core/override-configuration-spec.js | 10 +- tests/spec/core/ready-promise-spec.js | 2 +- tests/spec/core/remove-respec-spec.js | 4 +- tests/spec/core/requirements-spec.js | 3 +- tests/spec/core/section-refs-spec.js | 2 +- tests/spec/core/structure-spec.js | 43 +- tests/spec/core/ui-spec.js | 57 +- tests/spec/core/utils-spec.js | 181 +- tests/spec/core/webidl-contiguous-spec.js | 737 ++++---- tests/spec/w3c/abstract-spec.js | 4 +- tests/spec/w3c/headers-spec.js | 671 +++---- tests/spec/w3c/linter-spec.js | 66 +- tests/spec/w3c/local-aliases-spec.js | 12 +- tests/spec/w3c/permalinks-spec.js | 64 +- tests/spec/w3c/rdfa-spec.js | 74 +- tests/spec/w3c/seo-spec.js | 15 +- tests/spec/w3c/style-spec.js | 126 +- 87 files changed, 4724 insertions(+), 3746 deletions(-) diff --git a/js/core/beautify-options.js b/js/core/beautify-options.js index 08cb9c2c3e..8b46d00c97 100644 --- a/js/core/beautify-options.js +++ b/js/core/beautify-options.js @@ -3,14 +3,14 @@ define([], function() { // See http://jsbeautifier.org/js/lib/beautify-html.js // For what each one means. return Object.freeze({ - 'brace_style': 'expand', - 'extra_liners': ['section'], - 'indent_char': ' ', - 'indent_handlebars': false, - 'indent_inner_html': false, - 'indent_size': 2, - 'max_preserve_newlines': 5, - 'preserve_newlines': true, - 'wrap_line_length': 0, + brace_style: "expand", + extra_liners: ["section"], + indent_char: " ", + indent_handlebars: false, + indent_inner_html: false, + indent_size: 2, + max_preserve_newlines: 5, + preserve_newlines: true, + wrap_line_length: 0, }); }); diff --git a/js/core/issues-notes.js b/js/core/issues-notes.js index 9b8883507d..d193f4ef5d 100644 --- a/js/core/issues-notes.js +++ b/js/core/issues-notes.js @@ -11,11 +11,8 @@ // If the configuration has issueBase set to a non-empty string, and issues are // manually numbered, a link to the issue is created using issueBase and the issue number "use strict"; -define([ - "core/pubsubhub", - "deps/text!core/css/issues-notes.css", - "github", - ], +define( + ["core/pubsubhub", "deps/text!core/css/issues-notes.css", "github"], function(pubsubhub, css, github) { return { run: function(conf, doc, cb) { @@ -23,7 +20,9 @@ define([ $(doc).find("head link").first().before($("', returnEnd: true, - subLanguage: ['css', 'xml'] - } - }, - { - className: 'tag', - // See the comment in the ", returnEnd: true, - relevance: 0 + subLanguage: ["css", "xml"], }, - { - className: 'link', - begin: '\\]\\(', end: '\\)', - excludeBegin: true, excludeEnd: true - }, - { - className: 'symbol', - begin: '\\]\\[', end: '\\]', - excludeBegin: true, excludeEnd: true - } - ], - relevance: 10 - }, - { - begin: /^\[[^\n]+\]:/, - returnBegin: true, - contains: [ - { - className: 'symbol', - begin: /\[/, end: /\]/, - excludeBegin: true, excludeEnd: true + }, + { + className: "tag", + // See the comment in the "; $(doc).find("head link").first().before(style); @@ -30,11 +30,11 @@ export function run(conf, doc, cb) { $secs.each(function(i, item) { var $item = $(item); if (!$item.hasClass("nolink")) { - var resourceID = $item.attr('id'); + var resourceID = $item.attr("id"); var $par = $item.parent(); if ($par.is("section") || $par.is("div")) { if (!$par.hasClass("introductory") && !$par.hasClass("nolink")) { - resourceID = $par.attr('id'); + resourceID = $par.attr("id"); } else { resourceID = null; } @@ -44,21 +44,21 @@ export function run(conf, doc, cb) { // we have an id. add a permalink // right after the h* element var theNode = $(""); - theNode.attr('class', 'permalink'); - if (conf.doRDFa) theNode.attr('typeof', 'bookmark'); + theNode.attr("class", "permalink"); + if (conf.doRDFa) theNode.attr("typeof", "bookmark"); var ctext = $item.text(); var el = $(""); el.attr({ - href: '#' + resourceID, - 'aria-label': 'Permalink for ' + ctext, - title: 'Permalink for ' + ctext + href: "#" + resourceID, + "aria-label": "Permalink for " + ctext, + title: "Permalink for " + ctext, }); - if (conf.doRDFa) el.attr('property', 'url'); + if (conf.doRDFa) el.attr("property", "url"); var sym = $(""); if (conf.doRDFa) { sym.attr({ - property: 'title', - content: ctext + property: "title", + content: ctext, }); } sym.append(symbol); diff --git a/src/w3c/rfc2119.js b/src/w3c/rfc2119.js index 3dd914037d..d23f943bc6 100644 --- a/src/w3c/rfc2119.js +++ b/src/w3c/rfc2119.js @@ -12,8 +12,8 @@ export function run(conf, doc, cb) { } // do we have a list of used RFC2119 items in // conf.respecRFC2119 - const terms = Object.getOwnPropertyNames(conf.respecRFC2119) - + const terms = Object.getOwnPropertyNames(conf.respecRFC2119); + // there are no terms used - remove the clause if (terms.length === 0) { confo.remove(); @@ -21,7 +21,10 @@ export function run(conf, doc, cb) { } // put in the 2119 clause and reference - const html = joinAnd(terms.sort(), item => `${item}`); + const html = joinAnd( + terms.sort(), + item => `${item}` + ); const plural = terms.length > 1; const str = `The key word${plural ? "s " : " "} ${html} ${plural ? "are" : "is"} ${confo.innerHTML}`; confo.innerHTML = str; diff --git a/src/w3c/seo.js b/src/w3c/seo.js index eef7bbc0c8..6b3c26e643 100644 --- a/src/w3c/seo.js +++ b/src/w3c/seo.js @@ -4,14 +4,19 @@ import { pub } from "core/pubsubhub"; export function run(conf, doc, cb) { - var trLatestUri = conf.shortName ? 'https://www.w3.org/TR/' + conf.shortName + '/' : null; + var trLatestUri = conf.shortName + ? "https://www.w3.org/TR/" + conf.shortName + "/" + : null; switch (conf.canonicalURI) { case "edDraft": if (conf.edDraftURI) { conf.canonicalURI = new URL(conf.edDraftURI, doc.location).href; } else { - pub("warn", "Canonical URI set to edDraft, " + - "but no edDraftURI is set in configuration"); + pub( + "warn", + "Canonical URI set to edDraft, " + + "but no edDraftURI is set in configuration" + ); conf.canonicalURI = null; } break; @@ -19,8 +24,11 @@ export function run(conf, doc, cb) { if (trLatestUri) { conf.canonicalURI = trLatestUri; } else { - pub("warn", "Canonical URI set to TR, but " + - "no shortName is set in configuration"); + pub( + "warn", + "Canonical URI set to TR, but " + + "no shortName is set in configuration" + ); conf.canonicalURI = null; } break; @@ -29,8 +37,7 @@ export function run(conf, doc, cb) { try { conf.canonicalURI = new URL(conf.canonicalURI, doc.location).href; } catch (err) { - pub("warn", "CanonicalURI is an invalid URL: " + - err.message); + pub("warn", "CanonicalURI is an invalid URL: " + err.message); conf.canonicalURI = null; } } else if (trLatestUri) { diff --git a/src/w3c/style.js b/src/w3c/style.js index f49aa7be51..2d81f0dc5b 100644 --- a/src/w3c/style.js +++ b/src/w3c/style.js @@ -86,13 +86,10 @@ function createResourceHints() { }, ] .map(createResourceHint) - .reduce( - function(frag, link) { - frag.appendChild(link); - return frag; - }, - document.createDocumentFragment() - ); + .reduce(function(frag, link) { + frag.appendChild(link); + return frag; + }, document.createDocumentFragment()); return resourceHints; } // Collect elements for insertion diff --git a/tests/spec/SpecHelper.js b/tests/spec/SpecHelper.js index 6d68188317..b8a79d7532 100644 --- a/tests/spec/SpecHelper.js +++ b/tests/spec/SpecHelper.js @@ -15,7 +15,12 @@ function makeRSDoc(opts = {}, cb = () => {}, src = "about:blank", style = "") { var doc = this.contentDocument; decorateDocument(doc, opts); window.addEventListener("message", function msgHandler(ev) { - if (!doc || !ev.source || doc !== ev.source.document || ev.data.topic !== "end-all") { + if ( + !doc || + !ev.source || + doc !== ev.source.document || + ev.data.topic !== "end-all" + ) { return; } window.removeEventListener("message", msgHandler); @@ -29,7 +34,9 @@ function makeRSDoc(opts = {}, cb = () => {}, src = "about:blank", style = "") { try { ifr.style = style; } catch (err) { - console.warn("Could not override iframe style: " + style + " (" + err.message + ")"); + console.warn( + "Could not override iframe style: " + style + " (" + err.message + ")" + ); } } if (src) { @@ -53,17 +60,19 @@ function decorateDocument(doc, opts) { var config = this.ownerDocument.createElement("script"); var configText = ""; if (opts.config) { - configText = "var respecConfig = " + JSON.stringify(opts.config || {}) + ";"; + configText = + "var respecConfig = " + JSON.stringify(opts.config || {}) + ";"; } config.classList.add("remove"); config.innerText = configText; - var isKarma = (!!window.__karma__); + var isKarma = !!window.__karma__; var loadAttr = { - src: (isKarma) ? new URL("/base/builds/respec-w3c-common.js", location).href : "/js/deps/require.js", - "data-main": (isKarma) ? "" : path + (opts.profile || "profile-w3c-common") + src: isKarma + ? new URL("/base/builds/respec-w3c-common.js", location).href + : "/js/deps/require.js", + "data-main": isKarma ? "" : path + (opts.profile || "profile-w3c-common"), }; - Object - .keys(loadAttr) + Object.keys(loadAttr) .reduce(intoAttributes.bind(loadAttr), loader) .classList.add("remove"); this.appendChild(config); @@ -71,7 +80,8 @@ function decorateDocument(doc, opts) { } function decorateBody(opts) { - var bodyText = opts.abstract || "

test abstract

"; + var bodyText = + opts.abstract || "

test abstract

"; if (opts.body) { bodyText = bodyText.concat(opts.body); } @@ -79,9 +89,10 @@ function decorateDocument(doc, opts) { } if (opts.htmlAttrs) { - Object - .keys(opts.htmlAttrs) - .reduce(intoAttributes.bind(opts.htmlAttrs), doc.documentElement); + Object.keys(opts.htmlAttrs).reduce( + intoAttributes.bind(opts.htmlAttrs), + doc.documentElement + ); } if (opts.title) { doc.title = opts.title; @@ -104,11 +115,9 @@ function pickRandomsFromList(list, howMany) { } if (howMany > list.length) { // Return a new list, but randomized. - return list - .slice() - .sort(function randomSort() { - return Math.round(Math.random() * (1 - (-1)) + -1); - }); + return list.slice().sort(function randomSort() { + return Math.round(Math.random() * (1 - -1) + -1); + }); } var collectedValues = []; // collect a unique set based on howMany we need. @@ -127,9 +136,11 @@ function pickRandomsFromList(list, howMany) { function makeBasicConfig() { return { - editors: [{ - name: "Person Name" - }], + editors: [ + { + name: "Person Name", + }, + ], specStatus: "ED", edDraftURI: "http://foo.com", shortName: "Foo", @@ -152,4 +163,3 @@ function makeStandardOps() { body: makeDefaultBody(), }; } - diff --git a/tests/spec/core/best-practices-spec.js b/tests/spec/core/best-practices-spec.js index a32280ea02..faed3de90c 100644 --- a/tests/spec/core/best-practices-spec.js +++ b/tests/spec/core/best-practices-spec.js @@ -19,7 +19,9 @@ describe("Core — Best Practices", function() { var bps = doc.querySelector("#bp-summary"); expect(pls.item(0).textContent).toEqual("Best Practice 1: BP1"); expect(pls.item(1).textContent).toEqual("Best Practice 2: BP2"); - expect(bps.querySelector("h2, h3, h4, h5, h6").textContent).toEqual("Best Practices Summary"); + expect(bps.querySelector("h2, h3, h4, h5, h6").textContent).toEqual( + "Best Practices Summary" + ); expect(bps.querySelectorAll("ul li").length).toEqual(2); }).then(done); }); diff --git a/tests/spec/core/biblio-db-spec.js b/tests/spec/core/biblio-db-spec.js index 5dab452bb1..b0f858c56e 100644 --- a/tests/spec/core/biblio-db-spec.js +++ b/tests/spec/core/biblio-db-spec.js @@ -2,200 +2,188 @@ describe("Core - biblioDB", () => { const data = { "whatwg-dom": { - "aliasOf": "WHATWG-DOM" + aliasOf: "WHATWG-DOM", }, "WHATWG-DOM": { - "authors": [ - "Anne van Kesteren" - ], - "href": "https://dom.spec.whatwg.org/", - "title": "DOM Standard", - "status": "Living Standard", - "publisher": "WHATWG", - "id": "WHATWG-DOM" + authors: ["Anne van Kesteren"], + href: "https://dom.spec.whatwg.org/", + title: "DOM Standard", + status: "Living Standard", + publisher: "WHATWG", + id: "WHATWG-DOM", }, - "addAllTest": { - "id": "ADD-ALL-TEST", - "title": "ADD ALL TEST", + addAllTest: { + id: "ADD-ALL-TEST", + title: "ADD ALL TEST", }, - "DAHU": { - "aliasOf": "DAHUT", + DAHU: { + aliasOf: "DAHUT", }, - "DAHUT": { - "authors": [ - "Robin Berjon" - ], - "etAl": true, - "title": "The Dahut Specification Example From the Higher Circle", - "date": "15 March 1977", - "status": "Lazy Daft (Work for progress)", - "href": "http://berjon.com/", - "versions": [ + DAHUT: { + authors: ["Robin Berjon"], + etAl: true, + title: "The Dahut Specification Example From the Higher Circle", + date: "15 March 1977", + status: "Lazy Daft (Work for progress)", + href: "http://berjon.com/", + versions: [ "DAHUT-TEST6", "DAHUT-TEST5", "DAHUT-TEST4", "DAHUT-TEST3", "DAHUT-TEST2", - "DAHUT-TEST1" + "DAHUT-TEST1", ], - "id": "DAHUT", - } + id: "DAHUT", + }, }; var biblioDB; - beforeAll((done) => { + beforeAll(done => { require(["core/biblio-db", "deps/regenerator"], ({ biblioDB: db }) => { biblioDB = db; done(); }); }); describe("ready getter", () => { - it("resolves with a IDB database", (done) => { - biblioDB.ready.then((db) => { - expect(db instanceof window.IDBDatabase).toBe(true); - }).then(done); + it("resolves with a IDB database", done => { + biblioDB.ready + .then(db => { + expect(db instanceof window.IDBDatabase).toBe(true); + }) + .then(done); }); }); describe("add() method", () => { - it("rejects when adding bad types", (done) => { - biblioDB.add("invalid", "bar").catch( - err => expect(err instanceof TypeError).toBe(true) - ).then(done); + it("rejects when adding bad types", done => { + biblioDB + .add("invalid", "bar") + .catch(err => expect(err instanceof TypeError).toBe(true)) + .then(done); }); - it("rejects when adding empty type", (done) => { - biblioDB.add("", "ref").catch( - err => expect(err instanceof TypeError).toBe(true) - ).then(done); + it("rejects when adding empty type", done => { + biblioDB + .add("", "ref") + .catch(err => expect(err instanceof TypeError).toBe(true)) + .then(done); }); - it("adds single reference", (done) => { - biblioDB.add("reference", { - "authors": [ - "Test Author" - ], - "href": "https://test/", - "title": "test spec", - "status": "Living Standard", - "publisher": "W3C", - "id": "test123" - }).then( - () => biblioDB.has("reference", "test123") - ) - .then( - result => expect(result).toBe(true) - ) + it("adds single reference", done => { + biblioDB + .add("reference", { + authors: ["Test Author"], + href: "https://test/", + title: "test spec", + status: "Living Standard", + publisher: "W3C", + id: "test123", + }) + .then(() => biblioDB.has("reference", "test123")) + .then(result => expect(result).toBe(true)) .then(done); }); }); describe("addAll() method", () => { - it("adds both aliases and references", (done) => { + it("adds both aliases and references", done => { biblioDB .addAll(data) - .then( - () => Promise.all([ + .then(() => + Promise.all([ biblioDB.has("alias", "whatwg-dom"), biblioDB.has("reference", "ADD-ALL-TEST"), biblioDB.has("reference", "WHATWG-DOM"), ]) - ).then( - results => expect(results.every(v => v === true)).toBe(true) - ).then( - done - ); + ) + .then(results => expect(results.every(v => v === true)).toBe(true)) + .then(done); }); }); describe("get() method", () => { - it("rejects when getting invalid type", (done) => { - biblioDB.get("invalid", "bar").catch( - err => expect(err instanceof TypeError).toBe(true) - ).then(done); + it("rejects when getting invalid type", done => { + biblioDB + .get("invalid", "bar") + .catch(err => expect(err instanceof TypeError).toBe(true)) + .then(done); }); - it("rejects when id is missing", (done) => { - biblioDB.get("invalid").catch( - err => expect(err instanceof TypeError).toBe(true) - ).then(done); + it("rejects when id is missing", done => { + biblioDB + .get("invalid") + .catch(err => expect(err instanceof TypeError).toBe(true)) + .then(done); }); - it("retrieves a reference", (done) => { - biblioDB.add("reference", { - "href": "https://test/", - "title": "PASS", - "publisher": "W3C", - "id": "get-ref-test" - }).then( - () => biblioDB.get("reference", "get-ref-test") - ) - .then( - entry => expect(entry.title).toEqual("PASS") - ) + it("retrieves a reference", done => { + biblioDB + .add("reference", { + href: "https://test/", + title: "PASS", + publisher: "W3C", + id: "get-ref-test", + }) + .then(() => biblioDB.get("reference", "get-ref-test")) + .then(entry => expect(entry.title).toEqual("PASS")) .then(done); }); - it("retrieves an alias", (done) => { - biblioDB.add("alias", { - "id": "ALIAS-GET-TEST", - "aliasOf": "PASS", - }).then( - () => biblioDB.get("alias", "ALIAS-GET-TEST") - ) - .then( - entry => expect(entry.aliasOf).toEqual("PASS") - ) + it("retrieves an alias", done => { + biblioDB + .add("alias", { + id: "ALIAS-GET-TEST", + aliasOf: "PASS", + }) + .then(() => biblioDB.get("alias", "ALIAS-GET-TEST")) + .then(entry => expect(entry.aliasOf).toEqual("PASS")) .then(done); }); - it("returns null when it can't find an entry", (done) => { + it("returns null when it can't find an entry", done => { Promise.all([ - biblioDB.get("reference", "does not exist"), - biblioDB.get("alias", "does not exist"), - ]) - .then( - results => expect(results.every(v => v === null)).toBe(true) - ) + biblioDB.get("reference", "does not exist"), + biblioDB.get("alias", "does not exist"), + ]) + .then(results => expect(results.every(v => v === null)).toBe(true)) .then(done); }); }); describe("has() method", () => { - it("rejects on invalid type", (done) => { - biblioDB.has("invalid", "bar").catch( - err => expect(err instanceof TypeError).toBe(true) - ).then(done); + it("rejects on invalid type", done => { + biblioDB + .has("invalid", "bar") + .catch(err => expect(err instanceof TypeError).toBe(true)) + .then(done); }); - it("rejects when id is missing", (done) => { - biblioDB.has("invalid").catch( - err => expect(err instanceof TypeError).toBe(true) - ).then(done); + it("rejects when id is missing", done => { + biblioDB + .has("invalid") + .catch(err => expect(err instanceof TypeError).toBe(true)) + .then(done); }); - it("returns true when entries exist", (done) => { - Promise.all( - [ - biblioDB.add("reference", { - id: "has-ref-test", - "title": "pass", - }), - biblioDB.add("alias", { - id: "has-alias-test", - "aliasOf": "pass", - }) - ]).then( - () => Promise.all([ + it("returns true when entries exist", done => { + Promise.all([ + biblioDB.add("reference", { + id: "has-ref-test", + title: "pass", + }), + biblioDB.add("alias", { + id: "has-alias-test", + aliasOf: "pass", + }), + ]) + .then(() => + Promise.all([ biblioDB.has("reference", "has-ref-test"), biblioDB.has("alias", "has-alias-test"), ]) ) - .then( - result => expect(result.every(v => v === true)).toBe(true) - ) + .then(result => expect(result.every(v => v === true)).toBe(true)) .then(done); }); - it("returns false when entries don't exist", (done) => { + it("returns false when entries don't exist", done => { Promise.all([ - biblioDB.has("reference", "does not exist"), - biblioDB.has("alias", "does not exist"), - ]) - .then( - result => expect(result.every(v => v === false)).toBe(true) - ) + biblioDB.has("reference", "does not exist"), + biblioDB.has("alias", "does not exist"), + ]) + .then(result => expect(result.every(v => v === false)).toBe(true)) .then(done); }); }); describe("isAlias() method", () => { - it("rejects if passed a bad id", (done) => { + it("rejects if passed a bad id", done => { var p1 = biblioDB.isAlias(); var p2 = biblioDB.isAlias(null); var p3 = biblioDB.isAlias(""); @@ -205,18 +193,14 @@ describe("Core - biblioDB", () => { p3.catch(err => expect(err instanceof TypeError).toBe(true)), ]).then(done); }); - it("returns true when it is an alias", (done) => { + it("returns true when it is an alias", done => { biblioDB .add("alias", { aliasOf: "isAlias", id: "test-isAlias-pass" }) - .then( - () => biblioDB.isAlias("test-isAlias-pass") - ).then( - result => expect(result).toBe(true) - ).then( - done - ); + .then(() => biblioDB.isAlias("test-isAlias-pass")) + .then(result => expect(result).toBe(true)) + .then(done); }); - it("returns false when it is not an alias", (done) => { + it("returns false when it is not an alias", done => { biblioDB .isAlias("not an alias") .then(result => expect(result).toBe(false)) @@ -224,7 +208,7 @@ describe("Core - biblioDB", () => { }); }); describe("find() method", () => { - it("rejects if passed a bad id", (done) => { + it("rejects if passed a bad id", done => { var p1 = biblioDB.find(); var p2 = biblioDB.find(null); var p3 = biblioDB.find(""); @@ -234,28 +218,20 @@ describe("Core - biblioDB", () => { p3.catch(err => expect(err instanceof TypeError).toBe(true)), ]).then(done); }); - it("finds a references and resolves aliases", (done) => { + it("finds a references and resolves aliases", done => { biblioDB .addAll(data) - .then( - () => biblioDB.find("DAHU") - ) - .then( - result => expect(result.id).toEqual("DAHUT") - ) + .then(() => biblioDB.find("DAHU")) + .then(result => expect(result.id).toEqual("DAHUT")) .then( () => biblioDB.find("whatwg-dom") // alias ) - .then( - result => expect(result.title).toEqual("DOM Standard") - ) - .then( - done - ); + .then(result => expect(result.title).toEqual("DOM Standard")) + .then(done); }); }); describe("resolveAlias() method", () => { - it("rejects if passed a bad id", (done) => { + it("rejects if passed a bad id", done => { var p1 = biblioDB.resolveAlias(); var p2 = biblioDB.resolveAlias(null); var p3 = biblioDB.resolveAlias(""); @@ -265,27 +241,15 @@ describe("Core - biblioDB", () => { p3.catch(err => expect(err instanceof TypeError).toBe(true)), ]).then(done); }); - it("resolves known aliases or return null when alias is unknown", (done) => { + it("resolves known aliases or return null when alias is unknown", done => { biblioDB .addAll(data) - .then( - () => biblioDB.resolveAlias("whatwg-dom") - ) - .then( - result => expect(result).toEqual("WHATWG-DOM") - ) - .then( - () => biblioDB.resolveAlias("does not exist") - ) - .then( - result => expect(result).toBe(null) - ) - .then( - done - ); + .then(() => biblioDB.resolveAlias("whatwg-dom")) + .then(result => expect(result).toEqual("WHATWG-DOM")) + .then(() => biblioDB.resolveAlias("does not exist")) + .then(result => expect(result).toBe(null)) + .then(done); }); }); - describe("close() method", () => { - - }); + describe("close() method", () => {}); }); diff --git a/tests/spec/core/biblio-spec.js b/tests/spec/core/biblio-spec.js index c9c17b50a7..3178072203 100644 --- a/tests/spec/core/biblio-spec.js +++ b/tests/spec/core/biblio-spec.js @@ -10,7 +10,7 @@ describe("W3C — Bibliographic References", function() { // Ping biblio service to see if it's running it("should reach biblio service", function(done) { var fetchOps = { - method: "HEAD" + method: "HEAD", }; fetch(bibRefsURL, fetchOps) .then(function(res) { @@ -25,33 +25,35 @@ describe("W3C — Bibliographic References", function() { }); var customConfig = { - editors: [{ - name: "Robin Berjon" - }], + editors: [ + { + name: "Robin Berjon", + }, + ], shortName: "Foo", specStatus: "WD", prevVersion: "FPWD", previousMaturity: "WD", previousPublishDate: "2013-12-17", localBiblio: { - "TestRef1": { + TestRef1: { title: "Test ref title", href: "http://test.com", authors: ["William Shakespeare"], - publisher: "Publishers Inc." + publisher: "Publishers Inc.", }, - "TestRef2": { + TestRef2: { title: "Second test", href: "http://test.com", authors: ["Another author"], - publisher: "Testing 123" + publisher: "Testing 123", }, - "TestRef3": { + TestRef3: { title: "Third test", href: "http://test.com", - publisher: "Publisher Here" + publisher: "Publisher Here", }, - } + }, }; it("includes a dns-prefetch to bibref server", function(done) { @@ -61,10 +63,14 @@ describe("W3C — Bibliographic References", function() { }; makeRSDoc(ops, function(doc) { var host = bibRefsURL.host; - var link = doc.querySelector("link[rel='dns-prefetch'][href*='" + host + "']"); + var link = doc.querySelector( + "link[rel='dns-prefetch'][href*='" + host + "']" + ); expect(link).toBeTruthy(); expect(link.classList.contains("removeOnSave")).toBeTruthy(); - }).then(done).catch(done); + }) + .then(done) + .catch(done); }); it("should display the publisher when present", function(done) { @@ -78,7 +84,9 @@ describe("W3C — Bibliographic References", function() { expect(ref).toBeTruthy(); // This prevents Jasmine from taking down the whole test suite if SpecRef is down. if (!isSpecRefAvailable) { - var err = new Error("SpecRef seems to be down. Can't proceed with this spec."); + var err = new Error( + "SpecRef seems to be down. Can't proceed with this spec." + ); return Promise.reject(err); } expect(ref.textContent).toMatch(/Publishers Inc\.\s/); @@ -93,6 +101,8 @@ describe("W3C — Bibliographic References", function() { ref = doc.querySelector("#bib-TestRef3 + dd"); expect(ref).toBeTruthy(); expect(ref.textContent).toMatch(/Publisher Here\.\s/); - }).then(done).catch(done); + }) + .then(done) + .catch(done); }); -}); \ No newline at end of file +}); diff --git a/tests/spec/core/data-cite-spec.js b/tests/spec/core/data-cite-spec.js index 57e78bcbbe..129cd1948e 100644 --- a/tests/spec/core/data-cite-spec.js +++ b/tests/spec/core/data-cite-spec.js @@ -7,116 +7,141 @@ describe("Core — data-cite attribute", () => { it("links directly to externally defined references", done => { const ops = { config: makeBasicConfig(), - body: makeDefaultBody() + ` + body: makeDefaultBody() + + `

inline link

inline link

`, }; - 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"); - // Definition part - const dfn = doc.querySelector("#t2 > dfn"); - expect(dfn).toBeTruthy(); - const dfnA = doc.querySelector("#t2 > dfn > a"); - expect(dfnA.textContent).toEqual("inline link"); - expect(dfnA.href).toEqual("https://html.spec.whatwg.org/multipage/#test"); - expect(dfnA.hasAttribute("data-cite")).toEqual(false); - expect(doc.querySelector("#bib-WHATWG-HTML").closest("section").id) - .toEqual("normative-references"); - }).then(done); + 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"); + // Definition part + const dfn = doc.querySelector("#t2 > dfn"); + expect(dfn).toBeTruthy(); + const dfnA = doc.querySelector("#t2 > dfn > a"); + expect(dfnA.textContent).toEqual("inline link"); + expect(dfnA.href).toEqual( + "https://html.spec.whatwg.org/multipage/#test" + ); + expect(dfnA.hasAttribute("data-cite")).toEqual(false); + expect( + doc.querySelector("#bib-WHATWG-HTML").closest("section").id + ).toEqual("normative-references"); + }) + .then(done); }); it("links data-cite attributes as normative reference", done => { const ops = { config: makeBasicConfig(), - body: makeDefaultBody() + ` + body: makeDefaultBody() + + `

inline link

`, }; - 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/"); - expect(a.hasAttribute("data-cite")).toEqual(false); - expect(doc.querySelector("#bib-WHATWG-HTML").closest("section").id) - .toEqual("normative-references"); - }).then(done); + 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/"); + expect(a.hasAttribute("data-cite")).toEqual(false); + expect( + doc.querySelector("#bib-WHATWG-HTML").closest("section").id + ).toEqual("normative-references"); + }) + .then(done); }); it("links data-cite attributes as informative reference", done => { const ops = { config: makeBasicConfig(), - body: makeDefaultBody() + ` + body: makeDefaultBody() + + `

inline link

`, }; - makeRSDoc(ops).then(doc => { - const a = doc.querySelector("#t1 > a"); - expect(a.textContent).toEqual("inline link"); - expect(a.href).toEqual("https://dom.spec.whatwg.org/"); - expect(a.hasAttribute("data-cite")).toEqual(false); - expect(doc.querySelector("#bib-WHATWG-DOM").closest("section").id) - .toEqual("informative-references"); - }).then(done); + makeRSDoc(ops) + .then(doc => { + const a = doc.querySelector("#t1 > a"); + expect(a.textContent).toEqual("inline link"); + expect(a.href).toEqual("https://dom.spec.whatwg.org/"); + expect(a.hasAttribute("data-cite")).toEqual(false); + expect( + doc.querySelector("#bib-WHATWG-DOM").closest("section").id + ).toEqual("informative-references"); + }) + .then(done); }); it("handles bogus data-cite values", done => { const ops = { config: makeBasicConfig(), - body: makeDefaultBody() + ` + body: makeDefaultBody() + + `

link 1

link 2

`, }; - makeRSDoc(ops).then(doc => { - const a1 = doc.querySelector("#t1 > a"); - const a2 = doc.querySelector("#t2 > a"); - expect(a1.textContent).toEqual("link 1"); - expect(a2.textContent).toEqual("link 2"); - expect(a1.href).toEqual(""); - expect(a2.href).toEqual(""); - expect(a1.hasAttribute("data-cite")).toEqual(false); - expect(a2.hasAttribute("data-cite")).toEqual(false); - expect(doc.querySelector("#bib-no-exist-inf").closest("section").id) - .toEqual("informative-references"); - expect(doc.querySelector("#bib-no-exist-norm").closest("section").id) - .toEqual("normative-references"); - }).then(done); + makeRSDoc(ops) + .then(doc => { + const a1 = doc.querySelector("#t1 > a"); + const a2 = doc.querySelector("#t2 > a"); + expect(a1.textContent).toEqual("link 1"); + expect(a2.textContent).toEqual("link 2"); + expect(a1.href).toEqual(""); + expect(a2.href).toEqual(""); + expect(a1.hasAttribute("data-cite")).toEqual(false); + expect(a2.hasAttribute("data-cite")).toEqual(false); + expect( + doc.querySelector("#bib-no-exist-inf").closest("section").id + ).toEqual("informative-references"); + expect( + doc.querySelector("#bib-no-exist-norm").closest("section").id + ).toEqual("normative-references"); + }) + .then(done); }); it("adds the fragment identifier to the link", done => { const ops = { config: makeBasicConfig(), - body: makeDefaultBody() + ` + body: makeDefaultBody() + + `

inline link

`, }; - 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); + 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() + ` + body: makeDefaultBody() + + `

{

`, }; - 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); + 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() + ` + body: makeDefaultBody() + + `

{

`, }; - 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); + 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); }); }); }); diff --git a/tests/spec/core/data-include-spec.js b/tests/spec/core/data-include-spec.js index 66e8b8d23e..2abbf96126 100644 --- a/tests/spec/core/data-include-spec.js +++ b/tests/spec/core/data-include-spec.js @@ -6,7 +6,9 @@ describe("Core — Data Include", function() { }); // this does not test much, someone for whom this is // important should provide more tests - it("should include an external file and remove the data-include attr", function(done) { + it("should include an external file and remove the data-include attr", function( + done + ) { var url = "/tests/spec/core/includer.html"; var theTest = function(doc) { var p = doc.querySelector("#includes > div > p"); @@ -21,8 +23,7 @@ describe("Core — Data Include", function() { config: makeBasicConfig(), body: makeDefaultBody(), }; - makeRSDoc(ops, theTest, url) - .then(done); + makeRSDoc(ops, theTest, url).then(done); }); it("replaces sections when data-include-replace is present", function(done) { var url = "/tests/spec/core/includer.html"; @@ -39,8 +40,7 @@ describe("Core — Data Include", function() { config: makeBasicConfig(), body: makeDefaultBody(), }; - makeRSDoc(ops, theTest, url) - .then(done); + makeRSDoc(ops, theTest, url).then(done); }); it("gracefully handles empty data-includes", function(done) { var url = "/tests/spec/core/includer.html"; @@ -53,8 +53,7 @@ describe("Core — Data Include", function() { config: makeBasicConfig(), body: makeDefaultBody(), }; - makeRSDoc(ops, theTest, url) - .then(done); + makeRSDoc(ops, theTest, url).then(done); }); it("includes text when data-include-format is 'text'", function(done) { var url = "/tests/spec/core/includer.html"; @@ -67,8 +66,7 @@ describe("Core — Data Include", function() { config: makeBasicConfig(), body: makeDefaultBody(), }; - makeRSDoc(ops, theTest, url) - .then(done); + makeRSDoc(ops, theTest, url).then(done); }); it("includes a URL and processes it as markdown", function(done) { var theTest = function(doc) { @@ -82,11 +80,11 @@ describe("Core — Data Include", function() { var ops = { config: makeBasicConfig(), body: makeDefaultBody() + - "
", + "
", }; ops.config.format = "markdown"; - makeRSDoc(ops, theTest) - .then(done); + makeRSDoc(ops, theTest).then(done); }); - }); diff --git a/tests/spec/core/default-root-attr-spec.js b/tests/spec/core/default-root-attr-spec.js index 4457cfa635..5041eb04f7 100644 --- a/tests/spec/core/default-root-attr-spec.js +++ b/tests/spec/core/default-root-attr-spec.js @@ -20,7 +20,7 @@ describe("Core — Default Root Attribute", function() { var ops = { config: makeBasicConfig(), htmlAttrs: { - dir: "rtl" + dir: "rtl", }, body: makeDefaultBody(), }; @@ -34,7 +34,7 @@ describe("Core — Default Root Attribute", function() { var ops = { config: makeBasicConfig(), htmlAttrs: { - lang: "fr" + lang: "fr", }, body: makeDefaultBody(), }; diff --git a/tests/spec/core/dfn-spec.js b/tests/spec/core/dfn-spec.js index 3994eb70f4..8460f0a2cc 100644 --- a/tests/spec/core/dfn-spec.js +++ b/tests/spec/core/dfn-spec.js @@ -7,7 +7,8 @@ describe("Core — Definitions", function() { it("should process definitions", function(done) { var ops = { config: makeBasicConfig(), - body: makeDefaultBody() + "
texttext
", + body: makeDefaultBody() + + "
texttext
", }; makeRSDoc(ops, function(doc) { var $sec = $("#dfn", doc); @@ -16,7 +17,9 @@ describe("Core — Definitions", function() { }).then(done); }); - it("should make links when their definitions are ", function(done) { + it("should make links when their definitions are ", function( + done + ) { var ops = { config: makeBasicConfig(), body: makeDefaultBody() + @@ -33,10 +36,18 @@ describe("Core — Definitions", function() { }; makeRSDoc(ops, function(doc) { var $sec = $("#dfn", doc); - expect($sec.find("a:contains('outerCode')").contents()[0].nodeName).toEqual("CODE"); - expect($sec.find("a:contains('outerPre')").contents()[0].nodeName).toEqual("CODE"); - expect($sec.find("a:contains('innerCode')").contents()[0].nodeName).toEqual("CODE"); - expect($sec.find("a:contains('partial')").contents()[0].nodeName).toEqual("#text"); + expect( + $sec.find("a:contains('outerCode')").contents()[0].nodeName + ).toEqual("CODE"); + expect( + $sec.find("a:contains('outerPre')").contents()[0].nodeName + ).toEqual("CODE"); + expect( + $sec.find("a:contains('innerCode')").contents()[0].nodeName + ).toEqual("CODE"); + expect($sec.find("a:contains('partial')").contents()[0].nodeName).toEqual( + "#text" + ); }).then(done); }); @@ -44,13 +55,13 @@ describe("Core — Definitions", function() { var ops = { config: makeBasicConfig(), body: makeDefaultBody() + - ` + `
         interface Test {};
       

Test

not wrapped in code - ` + `, }; makeRSDoc(ops, doc => { const code = doc.querySelector("#t1 code"); @@ -58,7 +69,9 @@ describe("Core — Definitions", function() { const t2 = doc.querySelector("#t2"); expect(t2.querySelector("code")).toEqual(null); expect(t2.querySelector("a").textContent).toEqual("not wrapped in code"); - expect(t2.querySelector("a").getAttribute("href")).toEqual("#idl-def-test"); + expect(t2.querySelector("a").getAttribute("href")).toEqual( + "#idl-def-test" + ); }).then(done); }); @@ -73,7 +86,9 @@ describe("Core — Definitions", function() { }; makeRSDoc(ops, function(doc) { var $sec = $("#dfn", doc); - expect($sec.find("dfn").attr("data-lt")).toEqual("text|text 1|text 2|text 3"); + expect($sec.find("dfn").attr("data-lt")).toEqual( + "text|text 1|text 2|text 3" + ); expect($sec.find("dfn").attr("data-dfn-type")).toEqual("dfn"); }).then(done); }); @@ -92,5 +107,4 @@ describe("Core — Definitions", function() { expect($sec.find("dfn").attr("data-dfn-type")).toEqual("myType"); }).then(done); }); - }); diff --git a/tests/spec/core/figures-spec.js b/tests/spec/core/figures-spec.js index 95202e9080..b7f5028e9d 100644 --- a/tests/spec/core/figures-spec.js +++ b/tests/spec/core/figures-spec.js @@ -11,8 +11,8 @@ describe("Core - Figures", function() { "

" + "
PRE
" + " " + - "
"+ - "
"+ + " " + + "
" + "", }; it("generates captions for figures", function(done) { @@ -25,7 +25,7 @@ describe("Core - Figures", function() { expect(captions.item(1).textContent).toEqual("Fig. 2 IMGTIT"); }).then(done); }); - it("generates table of figures", function (done) { + it("generates table of figures", function(done) { makeRSDoc(ops, function(doc) { var tof = doc.getElementById("tof"); var tofHeader = tof.querySelector("h3"); diff --git a/tests/spec/core/highlight-spec.js b/tests/spec/core/highlight-spec.js index bd05aa9374..bdc3b86be8 100644 --- a/tests/spec/core/highlight-spec.js +++ b/tests/spec/core/highlight-spec.js @@ -8,13 +8,14 @@ describe("Core — Highlight", function() { it("shouldn't highlight idl blocks", done => { var ops = { config: makeBasicConfig(), - body: makeDefaultBody() + ` + body: makeDefaultBody() + + `
           [Constructor]interface Dahut : Mammal {
             const unsigned short DEXTROGYROUS = 1;
             Dahut turnAround(float angle, boolean fall);
           };
-
` + `, }; makeRSDoc(ops, function(doc) { var pre = doc.querySelector("pre"); @@ -33,12 +34,14 @@ describe("Core — Highlight", function() { alert('foo'); } - ` + `, }; makeRSDoc(ops, function(doc) { var pre = doc.querySelector("div.example pre"); expect(pre.classList.contains("hljs")).toBeTruthy(); - expect(pre.querySelectorAll("span[class^=hljs-]").length).toBeGreaterThan(0); + expect(pre.querySelectorAll("span[class^=hljs-]").length).toBeGreaterThan( + 0 + ); }).then(done); }); @@ -52,7 +55,7 @@ describe("Core — Highlight", function() { alert('foo'); } - ` + `, }; makeRSDoc(ops, function(doc) { var pre = doc.querySelector("div.example pre"); @@ -71,12 +74,11 @@ describe("Core — Highlight", function() { alert('foo'); } - ` + `, }; makeRSDoc(ops, function(doc) { var pre = doc.querySelector("#test"); expect(pre.querySelectorAll("span[class^=hljs-]").length).toBe(0); }).then(done); }); - }); diff --git a/tests/spec/core/id-headers-spec.js b/tests/spec/core/id-headers-spec.js index 8c8c17f693..b8777219d4 100644 --- a/tests/spec/core/id-headers-spec.js +++ b/tests/spec/core/id-headers-spec.js @@ -7,8 +7,7 @@ describe("Core - ID headers", function() { it("should have set ID on header", function(done) { var ops = { config: makeBasicConfig(), - body: makeDefaultBody() + - "

BLAH

FOO
" + body: makeDefaultBody() + "

BLAH

FOO
", }; makeRSDoc(ops, function(doc) { var $s = $("section h2:contains('FOO')", doc); diff --git a/tests/spec/core/include-config-spec.js b/tests/spec/core/include-config-spec.js index 7755093dee..7302ac483c 100644 --- a/tests/spec/core/include-config-spec.js +++ b/tests/spec/core/include-config-spec.js @@ -5,8 +5,8 @@ describe("Core — Include config as JSON", function() { done(); }); var ops; - beforeAll(function(done){ - ops = { + beforeAll(function(done) { + ops = { config: makeBasicConfig(), body: makeDefaultBody(), }; @@ -20,7 +20,9 @@ describe("Core — Include config as JSON", function() { expect(script.type).toEqual("application/json"); }).then(done); }); - it("should have the same content for the config and the script's text", function(done) { + it("should have the same content for the config and the script's text", function( + done + ) { const expected = JSON.stringify(makeBasicConfig(), null, 2); makeRSDoc(ops, function(doc) { var text = doc.getElementById("initialUserConfig").innerHTML; diff --git a/tests/spec/core/informative-spec.js b/tests/spec/core/informative-spec.js index c64f80d1a7..c00da3d114 100644 --- a/tests/spec/core/informative-spec.js +++ b/tests/spec/core/informative-spec.js @@ -14,7 +14,9 @@ describe("Core — Informative", function() { var $sec = $("div.informative, section.informative", doc); expect($sec.find("p").length).toEqual(1); expect($sec.find("p em").length).toEqual(1); - expect($sec.find("p em").text()).toEqual("This section is non-normative."); + expect($sec.find("p em").text()).toEqual( + "This section is non-normative." + ); }).then(done); }); }); diff --git a/tests/spec/core/inlines-spec.js b/tests/spec/core/inlines-spec.js index 30bfad68ea..0f2d2eab76 100644 --- a/tests/spec/core/inlines-spec.js +++ b/tests/spec/core/inlines-spec.js @@ -15,22 +15,28 @@ describe("Core - Inlines", function() { "", }; ops.config.localBiblio = { - "DAHU": { + DAHU: { title: "One short leg. How I learned to overcome.", - publisher: "Publishers Inc." + publisher: "Publishers Inc.", }, - "REX": { + REX: { title: "Am I a dinosaur or a failed technology?", - publisher: "Publishers Inc." + publisher: "Publishers Inc.", }, }; makeRSDoc(ops, function(doc) { var $inl = $("#inlines", doc); var $nr = $("#normative-references", doc); var $ir = $("#informative-references", doc); - expect($inl.find("abbr[title='ABBR-TIT']:contains('ABBR')").length).toEqual(2); - expect($inl.find("cite a:contains('DAHU')").attr("href")).toEqual("#bib-DAHU"); - expect($inl.find("cite a:contains('REX')").attr("href")).toEqual("#bib-REX"); + expect( + $inl.find("abbr[title='ABBR-TIT']:contains('ABBR')").length + ).toEqual(2); + expect($inl.find("cite a:contains('DAHU')").attr("href")).toEqual( + "#bib-DAHU" + ); + expect($inl.find("cite a:contains('REX')").attr("href")).toEqual( + "#bib-REX" + ); expect($nr.find("dl dt").length).toEqual(1); expect($nr.find("dl dt:contains('[DAHU]')").length).toEqual(1); expect($ir.find("dl dt").length).toEqual(1); diff --git a/tests/spec/core/issues-notes-spec.js b/tests/spec/core/issues-notes-spec.js index f3eb76a8af..3038ffd080 100644 --- a/tests/spec/core/issues-notes-spec.js +++ b/tests/spec/core/issues-notes-spec.js @@ -13,39 +13,46 @@ describe("Core — Issues and Notes", function() { "

BLAH ATR-INLINE

" + "

FEATURE AT RISK

" + "

BLAH NOT-INLINE

" + - "

NOTE

" + "

NOTE

", }; - makeRSDoc(ops, function(doc) { - var $iss = $("div.issue", doc).first(); - var $atr = $("div.atrisk", doc); - var $piss = $iss.find("p"); - var $patr = $atr.find("p"); - var $spiss = $("span.issue", doc); - var $spatr = $("span.atrisk", doc); - var $not = $("div.note", doc); - var $pnot = $not.find("p"); - var $spnot = $("span.note", doc); + makeRSDoc( + ops, + function(doc) { + var $iss = $("div.issue", doc).first(); + var $atr = $("div.atrisk", doc); + var $piss = $iss.find("p"); + var $patr = $atr.find("p"); + var $spiss = $("span.issue", doc); + var $spatr = $("span.atrisk", doc); + var $not = $("div.note", doc); + var $pnot = $not.find("p"); + var $spnot = $("span.note", doc); - expect($spiss.parent("div").length).toEqual(0); - expect($spatr.parent("div").length).toEqual(0); - expect($spnot.parent("div").length).toEqual(0); + expect($spiss.parent("div").length).toEqual(0); + expect($spatr.parent("div").length).toEqual(0); + expect($spnot.parent("div").length).toEqual(0); - expect($iss.find("div.issue-title").length).toEqual(1); - expect($iss.find("div.issue-title").text()).toEqual("Issue 1: ISS-TIT"); - expect($piss.attr("title")).toBeUndefined(); - expect($piss.text()).toEqual("ISSUE"); + expect($iss.find("div.issue-title").length).toEqual(1); + expect($iss.find("div.issue-title").text()).toEqual("Issue 1: ISS-TIT"); + expect($piss.attr("title")).toBeUndefined(); + expect($piss.text()).toEqual("ISSUE"); - expect($atr.find("div.issue-title").length).toEqual(1); - expect($atr.find("div.issue-title").text()).toEqual("Feature at Risk 2: ATR-TIT"); - expect($patr.attr("title")).toBeUndefined(); - expect($patr.text()).toEqual("FEATURE AT RISK"); + expect($atr.find("div.issue-title").length).toEqual(1); + expect($atr.find("div.issue-title").text()).toEqual( + "Feature at Risk 2: ATR-TIT" + ); + expect($patr.attr("title")).toBeUndefined(); + expect($patr.text()).toEqual("FEATURE AT RISK"); - expect($not.find("div.note-title").length).toEqual(1); - expect($not.find("div.note-title").text()).toEqual("Note: NOT-TIT"); - expect($pnot.attr("title")).toBeUndefined(); - expect($pnot.text()).toEqual("NOTE"); - done(); - }, null, "display: block;"); + expect($not.find("div.note-title").length).toEqual(1); + expect($not.find("div.note-title").text()).toEqual("Note: NOT-TIT"); + expect($pnot.attr("title")).toBeUndefined(); + expect($pnot.text()).toEqual("NOTE"); + done(); + }, + null, + "display: block;" + ); }); it("should process ednotes", function(done) { @@ -55,15 +62,22 @@ describe("Core — Issues and Notes", function() { "

BLAH EDNOTE-INLINE

" + "

EDNOTE

", }; - makeRSDoc(ops, function(doc) { - var $not = $("div.ednote", doc); - var $pnot = $not.find("p"); - expect($not.find("div.ednote-title").length).toEqual(1); - expect($not.find("div.ednote-title").text()).toEqual("Editor's Note: EDNOTE-TIT"); - expect($pnot.attr("title")).toBeUndefined(); - expect($pnot.text()).toEqual("EDNOTE"); - done(); - }, null, "display: block;"); + makeRSDoc( + ops, + function(doc) { + var $not = $("div.ednote", doc); + var $pnot = $not.find("p"); + expect($not.find("div.ednote-title").length).toEqual(1); + expect($not.find("div.ednote-title").text()).toEqual( + "Editor's Note: EDNOTE-TIT" + ); + expect($pnot.attr("title")).toBeUndefined(); + expect($pnot.text()).toEqual("EDNOTE"); + done(); + }, + null, + "display: block;" + ); }); it("should process warnings", function(done) { @@ -74,13 +88,18 @@ describe("Core — Issues and Notes", function() { "

WARNING

" + "

ISSUE

", }; - makeRSDoc(ops, function(doc) { - var $sec = $("section", doc); - expect($sec.find(".warning").length).toEqual(2); - expect($sec.find(".warning-title").length).toEqual(1); - expect($sec.find(".warning-title").text()).toEqual("Warning: WARN-TIT"); - done(); - }, null, "display: block;"); + makeRSDoc( + ops, + function(doc) { + var $sec = $("section", doc); + expect($sec.find(".warning").length).toEqual(2); + expect($sec.find(".warning-title").length).toEqual(1); + expect($sec.find(".warning-title").text()).toEqual("Warning: WARN-TIT"); + done(); + }, + null, + "display: block;" + ); }); it("should use data-number for issue and note numbers", function(done) { @@ -91,27 +110,36 @@ describe("Core — Issues and Notes", function() { "

Titled and Numbered Issue

" + "

Unnumbered ISSUE

", }; - makeRSDoc(ops, function(doc) { - var $i10 = $("#i10", doc).parent("div"); - var $i11 = $("#i11", doc).parent("div"); - var $ixx = $("#ixx", doc).parent("div"); - expect($i10.find("div.issue-title").length).toEqual(1); - expect($i10.find("div.issue-title").text()).toEqual("Issue 10"); + makeRSDoc( + ops, + function(doc) { + var $i10 = $("#i10", doc).parent("div"); + var $i11 = $("#i11", doc).parent("div"); + var $ixx = $("#ixx", doc).parent("div"); + expect($i10.find("div.issue-title").length).toEqual(1); + expect($i10.find("div.issue-title").text()).toEqual("Issue 10"); - expect($i11.find("div.issue-title").length).toEqual(1); - expect($i11.find("div.issue-title").text()).toEqual("Issue 11: ISS-TIT"); + expect($i11.find("div.issue-title").length).toEqual(1); + expect($i11.find("div.issue-title").text()).toEqual( + "Issue 11: ISS-TIT" + ); - expect($ixx.find("div.issue-title").length).toEqual(1); - expect($ixx.find("div.issue-title").text()).toEqual("Issue"); - done(); - }, null, "display: block;"); + expect($ixx.find("div.issue-title").length).toEqual(1); + expect($ixx.find("div.issue-title").text()).toEqual("Issue"); + done(); + }, + null, + "display: block;" + ); }); it("should link to external issue tracker", function(done) { var issueBaseConfig = { - editors: [{ - name: "Gregg Kellogg" - }], + editors: [ + { + name: "Gregg Kellogg", + }, + ], issueBase: "http://example.com/issues/", specStatus: "FPWD", shortName: "foo", @@ -121,23 +149,34 @@ describe("Core — Issues and Notes", function() { body: makeDefaultBody() + "

ISSUE

", }; - makeRSDoc(ops, function(doc) { - var $iss = $("div.issue", doc); - var $piss = $iss.find("p"); - expect($iss.find("div.issue-title").length).toEqual(1); - expect($iss.find("div.issue-title").text()).toEqual("Issue 10"); - expect($iss.find("div.issue-title a").attr("href")).toEqual(issueBaseConfig.issueBase + "10"); - expect($piss.attr("title")).toBeUndefined(); - expect($piss.text()).toEqual("ISSUE"); - done(); - }, null, "display: block;"); + makeRSDoc( + ops, + function(doc) { + var $iss = $("div.issue", doc); + var $piss = $iss.find("p"); + expect($iss.find("div.issue-title").length).toEqual(1); + expect($iss.find("div.issue-title").text()).toEqual("Issue 10"); + expect($iss.find("div.issue-title a").attr("href")).toEqual( + issueBaseConfig.issueBase + "10" + ); + expect($piss.attr("title")).toBeUndefined(); + expect($piss.text()).toEqual("ISSUE"); + done(); + }, + null, + "display: block;" + ); }); - it("should link to external issue tracker for features at risk", function(done) { + it("should link to external issue tracker for features at risk", function( + done + ) { var atRiskBaseConfig = { - editors: [{ - name: "Markus Lanthaler" - }], + editors: [ + { + name: "Markus Lanthaler", + }, + ], issueBase: "http://example.com/issues/", atRiskBase: "http://example.com/atrisk/", specStatus: "FPWD", @@ -148,15 +187,24 @@ describe("Core — Issues and Notes", function() { body: makeDefaultBody() + "

FEATURE AT RISK

", }; - makeRSDoc(ops, function(doc) { - var $iss = $("div.atrisk", doc); - var $piss = $iss.find("p"); - expect($iss.find("div.issue-title").length).toEqual(1); - expect($iss.find("div.issue-title").text()).toEqual("Feature at Risk 10"); - expect($iss.find("div.issue-title a").attr("href")).toEqual(atRiskBaseConfig.atRiskBase + "10"); - expect($piss.attr("title")).toBeUndefined(); - expect($piss.text()).toEqual("FEATURE AT RISK"); - done(); - }, null, "display: block;"); + makeRSDoc( + ops, + function(doc) { + var $iss = $("div.atrisk", doc); + var $piss = $iss.find("p"); + expect($iss.find("div.issue-title").length).toEqual(1); + expect($iss.find("div.issue-title").text()).toEqual( + "Feature at Risk 10" + ); + expect($iss.find("div.issue-title a").attr("href")).toEqual( + atRiskBaseConfig.atRiskBase + "10" + ); + expect($piss.attr("title")).toBeUndefined(); + expect($piss.text()).toEqual("FEATURE AT RISK"); + done(); + }, + null, + "display: block;" + ); }); }); diff --git a/tests/spec/core/jquery-enhanced-spec.js b/tests/spec/core/jquery-enhanced-spec.js index c78657d641..21db9c8489 100644 --- a/tests/spec/core/jquery-enhanced-spec.js +++ b/tests/spec/core/jquery-enhanced-spec.js @@ -1,7 +1,7 @@ "use strict"; describe("Core - jquery enhanced", function() { - beforeAll(function(done){ - require(["core/jquery-enhanced"], function(){ + beforeAll(function(done) { + require(["core/jquery-enhanced"], function() { done(); }); }); @@ -13,7 +13,9 @@ describe("Core - jquery enhanced", function() { // $.renameElement() it("should rename the element", function(done) { - var $div = $("

some text
").appendTo($("body")); + var $div = $("

some text
").appendTo( + $("body") + ); $div.find("p").renameElement("span"); $div.find("b").renameElement("i"); expect($div.find("span").length).toEqual(1); @@ -26,7 +28,7 @@ describe("Core - jquery enhanced", function() { it("should not prepend empty dfns to data-lt", function(done) { var $dfn = $("").appendTo($("body")); var titles = $dfn.getDfnTitles({ - isDefinition: true + isDefinition: true, }); expect(titles[0]).toEqual("dfn"); expect(titles[1]).toEqual("dfn2"); @@ -36,10 +38,14 @@ describe("Core - jquery enhanced", function() { }); // $.getDfnTitles() - it("should not use the text content when data-lt-noDefault is present", function(done) { - var $dfn = $("FAIL").appendTo($("body")); + it("should not use the text content when data-lt-noDefault is present", function( + done + ) { + var $dfn = $( + "FAIL" + ).appendTo($("body")); var titles = $dfn.getDfnTitles({ - isDefinition: true + isDefinition: true, }); expect(titles[0]).toEqual("dfn"); expect(titles[1]).toEqual("dfn2"); @@ -51,9 +57,11 @@ describe("Core - jquery enhanced", function() { // $.getDfnTitles() it("should find the data-lts", function(done) { - var $dfn = $("TEXT").appendTo($("body")); + var $dfn = $( + "TEXT" + ).appendTo($("body")); var titles = $dfn.getDfnTitles({ - isDefinition: true + isDefinition: true, }); expect(titles[0]).toEqual("text"); expect(titles[1]).toEqual("dfn"); @@ -69,9 +77,11 @@ describe("Core - jquery enhanced", function() { // $.getDfnTitles() it("should find the definition title", function(done) { - var $dfn = $("TEXT").appendTo($("body")); + var $dfn = $( + "TEXT" + ).appendTo($("body")); var titles = $dfn.getDfnTitles({ - isDefinition: true + isDefinition: true, }); expect(titles[0]).toEqual("text"); expect(titles[1]).toEqual("dfn"); @@ -89,7 +99,7 @@ describe("Core - jquery enhanced", function() { it("should return list of terms when called a second time", function(done) { var $dfn = $("TEXT").appendTo($("body")); var titles = $dfn.getDfnTitles({ - isDefinition: true + isDefinition: true, }); expect(titles[0]).toEqual("text"); expect(titles[1]).toEqual("dfn"); @@ -115,7 +125,9 @@ describe("Core - jquery enhanced", function() { expect($("

A--Bé9\n C

").makeID()).toEqual("a--b-9-c"); expect($("

").makeID()).toEqual("generatedID"); expect($("

2017

").makeID()).toEqual("x2017"); - var $div = $("

A
").appendTo($("body")); + var $div = $( + "

A
" + ).appendTo($("body")); expect($div.find("span").makeID()).toEqual("a-2"); $div.remove(); done(); @@ -123,7 +135,9 @@ describe("Core - jquery enhanced", function() { // $.allTextNodes() it("should find all the text nodes", function(done) { - var tns = $("
aabb

ccdd

nope
").allTextNodes(["pre"]); + var tns = $( + "
aabb

ccdd

nope
" + ).allTextNodes(["pre"]); expect(tns.length).toEqual(4); var str = ""; for (var i = 0, n = tns.length; i < n; i++) { diff --git a/tests/spec/core/markdown-spec.js b/tests/spec/core/markdown-spec.js index 464a66a88c..17662fa313 100644 --- a/tests/spec/core/markdown-spec.js +++ b/tests/spec/core/markdown-spec.js @@ -7,16 +7,13 @@ describe("Core - Markdown", function() { it("should process standard markdown content", function(done) { var ops = { config: makeBasicConfig(), - body: makeDefaultBody() + - "\n\nFoo\n===\n", + body: makeDefaultBody() + "\n\nFoo\n===\n", }; ops.config.format = "markdown"; makeRSDoc(ops, function(doc) { - Array - .from(doc.querySelectorAll(".removeOnSave")) - .forEach(function(elem) { - elem.remove(); - }); + Array.from(doc.querySelectorAll(".removeOnSave")).forEach(function(elem) { + elem.remove(); + }); var foo = doc.getElementById("foo"); expect(foo).toBeTruthy(); expect(foo.textContent).toEqual("1. Foo"); @@ -26,8 +23,7 @@ describe("Core - Markdown", function() { it("should process markdown inside of sections", function(done) { var ops = { config: makeBasicConfig(), - body: makeDefaultBody() + - "
\nFoo\n===\n
", + body: makeDefaultBody() + "
\nFoo\n===\n
", }; ops.config.format = "markdown"; makeRSDoc(ops, function(doc) { @@ -37,7 +33,9 @@ describe("Core - Markdown", function() { }).then(done); }); - it("should process markdown inside of notes, issues and reqs.", function(done) { + it("should process markdown inside of notes, issues and reqs.", function( + done + ) { var ops = { config: makeBasicConfig(), body: makeDefaultBody() + @@ -52,7 +50,9 @@ describe("Core - Markdown", function() { }).then(done); }); - it("should remove left padding before processing markdown content", function(done) { + it("should remove left padding before processing markdown content", function( + done + ) { var ops = { config: makeBasicConfig(), body: makeDefaultBody() + @@ -62,7 +62,9 @@ describe("Core - Markdown", function() { makeRSDoc(ops, function(doc) { expect(doc.querySelector("code")).toBeFalsy(); expect(doc.querySelector("#foo").textContent === "Foo"); - var listItems = doc.querySelectorAll("section > ul:not([class=toc]) > li"); + var listItems = doc.querySelectorAll( + "section > ul:not([class=toc]) > li" + ); expect(listItems.length).toEqual(2); expect(listItems[0].textContent).toEqual("list item 1"); var nestedLi = doc.querySelector("li > ul > li"); @@ -71,7 +73,9 @@ describe("Core - Markdown", function() { }).then(done); }); - it("should structure content in nested sections with appropriate titles", function(done) { + it("should structure content in nested sections with appropriate titles", function( + done + ) { var ops = { config: makeBasicConfig(), body: makeDefaultBody() + @@ -128,7 +132,9 @@ describe("Core - Markdown", function() { }).then(done); }); - it("should nest sections according to their first header, if present", function(done) { + it("should nest sections according to their first header, if present", function( + done + ) { var ops = { config: makeBasicConfig(), body: makeDefaultBody() + @@ -156,7 +162,9 @@ describe("Core - Markdown", function() { }).then(done); }); - it("should not nest content following a section inside of said section", function(done) { + it("should not nest content following a section inside of said section", function( + done + ) { var ops = { config: makeBasicConfig(), body: makeDefaultBody() + @@ -202,15 +210,18 @@ describe("Core - Markdown", function() { }); describe("nolinks options", function() { - it("automatically links URLs in pre when missing (smoke test)", function(done) { + it("automatically links URLs in pre when missing (smoke test)", function( + done + ) { var ops = { config: makeBasicConfig(), - body: makeDefaultBody() + ` + body: makeDefaultBody() + + `
this won't link this will link: http://no-links-foo.com so will this: http://no-links-bar.com -
` + `, }; ops.config.format = "markdown"; makeRSDoc(ops, function(doc) { @@ -224,19 +235,24 @@ describe("Core - Markdown", function() { it("replaces HTMLAnchors when present", function(done) { var ops = { config: makeBasicConfig(), - body: makeDefaultBody() + ` + body: makeDefaultBody() + + `