From ba7a73dc37cd0d6a9e755a7f2cc554623c68f832 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 12 Feb 2018 13:21:04 +0900 Subject: [PATCH 1/5] fix: ping in ordering-safe way --- tests/spec/core/biblio-spec.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/spec/core/biblio-spec.js b/tests/spec/core/biblio-spec.js index 7fd1a94895..5418330b38 100644 --- a/tests/spec/core/biblio-spec.js +++ b/tests/spec/core/biblio-spec.js @@ -59,7 +59,7 @@ describe("W3C — Bibliographic References", () => { `; afterAll(flushIframes); - let isSpecRefAvailable = false; + const specRefPing = fetch(bibRefsURL, { method: "HEAD" }); const bibRefsURL = new URL("https://specref.herokuapp.com/bibrefs"); let doc; @@ -68,9 +68,8 @@ describe("W3C — Bibliographic References", () => { }); it("pings biblio service to see if it's running", async () => { - const res = await fetch(bibRefsURL, { method: "HEAD" }); + const res = await specRefPing; expect(res.ok).toBeTruthy(); - isSpecRefAvailable = res.ok; }); it("includes a dns-prefetch to bibref server", () => { @@ -85,7 +84,7 @@ describe("W3C — Bibliographic References", () => { let ref = doc.querySelector("#bib-TestRef1 + dd"); expect(ref).toBeTruthy(); // This prevents Jasmine from taking down the whole test suite if SpecRef is down. - if (!isSpecRefAvailable) { + if (!(await specRefPing).ok) { throw new Error( "SpecRef seems to be down. Can't proceed with this spec." ); From 6959e047669fa869f5ee50be7ec89a490547911d Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 12 Feb 2018 13:21:55 +0900 Subject: [PATCH 2/5] variable ordering is still important --- tests/spec/core/biblio-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/spec/core/biblio-spec.js b/tests/spec/core/biblio-spec.js index 5418330b38..6d20126ecc 100644 --- a/tests/spec/core/biblio-spec.js +++ b/tests/spec/core/biblio-spec.js @@ -59,8 +59,8 @@ describe("W3C — Bibliographic References", () => { `; afterAll(flushIframes); - const specRefPing = fetch(bibRefsURL, { method: "HEAD" }); const bibRefsURL = new URL("https://specref.herokuapp.com/bibrefs"); + const specRefPing = fetch(bibRefsURL, { method: "HEAD" }); let doc; beforeAll(async () => { From 4b31c942e6ce8efd2defffbf1b288a81550e1af9 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 12 Feb 2018 13:39:43 +0900 Subject: [PATCH 3/5] specRefOk --- tests/spec/core/biblio-spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/spec/core/biblio-spec.js b/tests/spec/core/biblio-spec.js index 6d20126ecc..f0892009a4 100644 --- a/tests/spec/core/biblio-spec.js +++ b/tests/spec/core/biblio-spec.js @@ -60,11 +60,12 @@ describe("W3C — Bibliographic References", () => { afterAll(flushIframes); const bibRefsURL = new URL("https://specref.herokuapp.com/bibrefs"); - const specRefPing = fetch(bibRefsURL, { method: "HEAD" }); let doc; + let specRefOk; beforeAll(async () => { doc = await makeRSDoc({ config, body }); + specRefOk = (await fetch(bibRefsURL, { method: "HEAD" })).ok; }); it("pings biblio service to see if it's running", async () => { From 75bf71018d01f4a9fc61d81e4b0272f21f50e08a Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 12 Feb 2018 13:45:43 +0900 Subject: [PATCH 4/5] use specrefok --- tests/spec/core/biblio-spec.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/spec/core/biblio-spec.js b/tests/spec/core/biblio-spec.js index f0892009a4..06c5505a5e 100644 --- a/tests/spec/core/biblio-spec.js +++ b/tests/spec/core/biblio-spec.js @@ -68,9 +68,8 @@ describe("W3C — Bibliographic References", () => { specRefOk = (await fetch(bibRefsURL, { method: "HEAD" })).ok; }); - it("pings biblio service to see if it's running", async () => { - const res = await specRefPing; - expect(res.ok).toBeTruthy(); + it("pings biblio service to see if it's running", () => { + expect(specRefOk).toBeTruthy(); }); it("includes a dns-prefetch to bibref server", () => { @@ -85,7 +84,7 @@ describe("W3C — Bibliographic References", () => { let ref = doc.querySelector("#bib-TestRef1 + dd"); expect(ref).toBeTruthy(); // This prevents Jasmine from taking down the whole test suite if SpecRef is down. - if (!(await specRefPing).ok) { + if (!specRefOk.ok) { throw new Error( "SpecRef seems to be down. Can't proceed with this spec." ); From f1e731e8ab1b66c45a813698004b9089418c9b6d Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Mon, 12 Feb 2018 13:53:07 +0900 Subject: [PATCH 5/5] no need to access .ok --- tests/spec/core/biblio-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/spec/core/biblio-spec.js b/tests/spec/core/biblio-spec.js index 06c5505a5e..1be0ee41b7 100644 --- a/tests/spec/core/biblio-spec.js +++ b/tests/spec/core/biblio-spec.js @@ -84,7 +84,7 @@ describe("W3C — Bibliographic References", () => { let ref = doc.querySelector("#bib-TestRef1 + dd"); expect(ref).toBeTruthy(); // This prevents Jasmine from taking down the whole test suite if SpecRef is down. - if (!specRefOk.ok) { + if (!specRefOk) { throw new Error( "SpecRef seems to be down. Can't proceed with this spec." );