[Pkg-javascript-commits] [node-tap] 57/186: More unit tests for test class

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 1 16:40:43 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-tap.

commit 5ef65195a5306b857175d329cee953ea2f030d72
Author: isaacs <i at izs.me>
Date:   Tue Oct 31 22:40:05 2017 -0700

    More unit tests for test class
---
 tap-snapshots/unit-test.js-TAP.js | 24 +++++++++++++++++++++---
 unit/test.js                      | 26 +++++++++++++++++++++++---
 2 files changed, 44 insertions(+), 6 deletions(-)

diff --git a/tap-snapshots/unit-test.js-TAP.js b/tap-snapshots/unit-test.js-TAP.js
index 93c51d8..cc720cb 100644
--- a/tap-snapshots/unit-test.js-TAP.js
+++ b/tap-snapshots/unit-test.js-TAP.js
@@ -14,20 +14,25 @@ exports[`comment_0`] = `TAP version 13
 1..0
 `
 
+exports[`pragma_0`] = `TAP version 13
+pragma +strict
+1..0
+`
+
 exports[`todo_0`] = `TAP version 13
 not ok 1 - i will do this later # TODO
   ---
   at:
-    line: 22
+    line: 27
     column: 10
     file: unit/test.js
     function: todo
   source: |
-    tt.fail('i will do this later', { todo: true })
+    tt.notOk(true, 'i will do this later', { todo: true })
   ...
 
 ok 2 - i will do this later # TODO
-not ok 3 - this is fine # SKIP
+not ok 3 - expect truthy value # SKIP
 ok 4 - i did not do this later # SKIP
 1..4
 # todo: 2
@@ -87,3 +92,16 @@ ok 3 - promisey # {time}
 
 1..3
 `
+
+exports[`parallel sub_0`] = `TAP version 13
+1..2
+ok 1 - slow child # {time} {
+    1..0
+}
+
+ok 2 - fast child # {time} {
+    ok 1 - slow is going
+    1..1
+}
+
+`
diff --git a/unit/test.js b/unit/test.js
index 99ddf69..021fa67 100644
--- a/unit/test.js
+++ b/unit/test.js
@@ -18,12 +18,17 @@ t.test('short output checks', t => {
       tt.end()
     },
 
+    'pragma': tt => {
+      tt.pragma({ strict: true })
+      tt.end()
+    },
+
     'todo': tt => {
-      tt.fail('i will do this later', { todo: true })
+      tt.notOk(true, 'i will do this later', { todo: true })
       tt.todo('i will do this later', tt => {
         throw 'oh no'
       })
-      tt.fail('this is fine', { skip: true })
+      tt.ok(false, { message: 'this is fine', skip: true })
       tt.skip('i did not do this later', tt => {
         throw 'oops'
       })
@@ -69,6 +74,20 @@ t.test('short output checks', t => {
       }))
       tt.end()
     },
+
+    'parallel sub': tt => {
+      tt.jobs = 2
+      tt.plan(2)
+      let slowGoing = true
+      tt.test('slow child', tt => setTimeout(_ => {
+        slowGoing = false
+        tt.end()
+      }, 100))
+      tt.test('fast child', tt => setTimeout(_ => {
+        tt.ok(slowGoing, 'slow is going')
+        tt.end()
+      }))
+    },
   }
 
   const keys = Object.keys(cases)
@@ -81,7 +100,8 @@ t.test('short output checks', t => {
       let out = ''
       tt.on('data', c => out += c)
       tt.on('end', _ => {
-        out = out.replace(/ # time=[0-9\.]+m?s\n/g, ' # {time}\n')
+        out = out.replace(
+          / # time=[0-9\.]+m?s( \{.*)?\n/g, ' # {time}$1\n')
         t.matchSnapshot(out, i)
       })
       cases[i](tt)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-tap.git



More information about the Pkg-javascript-commits mailing list