jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/376492 )

Change subject: Chore: Make server/components/Page tests more self explanatory
......................................................................


Chore: Make server/components/Page tests more self explanatory

A bit more verbosity on the test subjects, and on the failure messages
when the test fails.

Instead of:

  1) Page() corporeal

      AssertionError [ERR_ASSERTION]: false == true      + expected - actual

      -false
      +true
      at Context.it (test/server/components/Page/index.test.ts:8:12)

  2) Page() incorporeal

      AssertionError [ERR_ASSERTION]: false == true
      + expected - actual

      -false
      +true

      at Context.it (test/server/components/Page/index.test.ts:13:12)

With the patch applied we would see:

  1) Page() contains a root div with the children when rendered:

      AssertionError [ERR_ASSERTION]: Could not find
<div id="root">body</div>

in
<div></div>
      + expected - actual

      -false
      +true

      at Context.it (test/server/components/Page/index.test.ts:10:12)

  2) Page() contains a <title/> when rendered:

      AssertionError [ERR_ASSERTION]: Could not find

<title>Test - Marvin</title>

in

<div></div>
      + expected - actual

      -false
      +true

      at

---

If we rely a lot on string checking on tests in the future we can
extract an assertStringIncludes helper for the tests.

Change-Id: I6508c755253c2b2c55e727c1b09dff0b34bfbbcb
---
M test/server/components/Page/index.test.ts
1 file changed, 15 insertions(+), 5 deletions(-)

Approvals:
  Niedzielski: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/test/server/components/Page/index.test.ts 
b/test/server/components/Page/index.test.ts
index 04f1daf..2a0ebdc 100644
--- a/test/server/components/Page/index.test.ts
+++ b/test/server/components/Page/index.test.ts
@@ -2,14 +2,24 @@
 import Page from "../../../../src/server/components/Page";
 import { render } from "preact-render-to-string";
 
-describe("page()", () => {
-  it("corporeal", () => {
+describe("Page()", () => {
+  it("contains a root div with the children when rendered", () => {
     const vNode = Page({ title: "Test", manifest: "", children: ["body"] });
-    assert.ok(render(vNode).includes('<div id="root">body</div>'));
+    const html = render(vNode);
+    const expected = '<div id="root">body</div>';
+    assert.ok(
+      html.includes(expected),
+      `Could not find \n\n${expected}\n\nin\n\n${html}`
+    );
   });
 
-  it("incorporeal", () => {
+  it("contains a <title/> when rendered", () => {
     const vNode = Page({ title: "Test", manifest: "" });
-    assert.ok(render(vNode).includes("<title>Test - Marvin</title>"));
+    const html = render(vNode);
+    const expected = "<title>Test - Marvin</title>";
+    assert.ok(
+      html.includes(expected),
+      `Could not find \n\n${expected}\n\nin\n\n${html}`
+    );
   });
 });

-- 
To view, visit https://gerrit.wikimedia.org/r/376492
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6508c755253c2b2c55e727c1b09dff0b34bfbbcb
Gerrit-PatchSet: 1
Gerrit-Project: marvin
Gerrit-Branch: master
Gerrit-Owner: Jhernandez <[email protected]>
Gerrit-Reviewer: Niedzielski <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to