[Pkg-javascript-commits] [node-tap] 54/186: first pass at unit test 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 22f1cc78894f7703ff815be871fb10094b343a77
Author: isaacs <i at izs.me>
Date: Tue Oct 31 21:42:27 2017 -0700
first pass at unit test for Test class
---
...unit-test.js-TAP-short-output-checks-comment.js | 5 ++
...-test.js-TAP-short-output-checks-expect-fail.js | 5 ++
...test.js-TAP-short-output-checks-no-plan-fail.js | 6 ++
...unit-test.js-TAP-short-output-checks-no-plan.js | 5 ++
...it-test.js-TAP-short-output-checks-plan-fail.js | 6 ++
.../unit-test.js-TAP-short-output-checks-plan.js | 5 ++
.../unit-test.js-TAP-short-output-checks-sub.js | 19 +++++
.../unit-test.js-TAP-short-output-checks-todo.js | 20 ++++++
unit/test.js | 81 ++++++++++++++++++++++
9 files changed, 152 insertions(+)
diff --git a/tap-snapshots/unit-test.js-TAP-short-output-checks-comment.js b/tap-snapshots/unit-test.js-TAP-short-output-checks-comment.js
new file mode 100644
index 0000000..ccbc561
--- /dev/null
+++ b/tap-snapshots/unit-test.js-TAP-short-output-checks-comment.js
@@ -0,0 +1,5 @@
+'use strict'
+exports[`comment_0`] = `TAP version 13
+# this is fine
+1..0
+`
diff --git a/tap-snapshots/unit-test.js-TAP-short-output-checks-expect-fail.js b/tap-snapshots/unit-test.js-TAP-short-output-checks-expect-fail.js
new file mode 100644
index 0000000..5fd2df7
--- /dev/null
+++ b/tap-snapshots/unit-test.js-TAP-short-output-checks-expect-fail.js
@@ -0,0 +1,5 @@
+'use strict'
+exports[`expect fail_0`] = `TAP version 13
+1..1
+ok 1 - this is fine
+`
diff --git a/tap-snapshots/unit-test.js-TAP-short-output-checks-no-plan-fail.js b/tap-snapshots/unit-test.js-TAP-short-output-checks-no-plan-fail.js
new file mode 100644
index 0000000..bb57c07
--- /dev/null
+++ b/tap-snapshots/unit-test.js-TAP-short-output-checks-no-plan-fail.js
@@ -0,0 +1,6 @@
+'use strict'
+exports[`no plan fail_0`] = `TAP version 13
+not ok 1 - this is fine
+1..1
+# failed 1 test
+`
diff --git a/tap-snapshots/unit-test.js-TAP-short-output-checks-no-plan.js b/tap-snapshots/unit-test.js-TAP-short-output-checks-no-plan.js
new file mode 100644
index 0000000..bc13dec
--- /dev/null
+++ b/tap-snapshots/unit-test.js-TAP-short-output-checks-no-plan.js
@@ -0,0 +1,5 @@
+'use strict'
+exports[`no plan_0`] = `TAP version 13
+ok 1 - this is fine
+1..1
+`
diff --git a/tap-snapshots/unit-test.js-TAP-short-output-checks-plan-fail.js b/tap-snapshots/unit-test.js-TAP-short-output-checks-plan-fail.js
new file mode 100644
index 0000000..aef3857
--- /dev/null
+++ b/tap-snapshots/unit-test.js-TAP-short-output-checks-plan-fail.js
@@ -0,0 +1,6 @@
+'use strict'
+exports[`plan fail_0`] = `TAP version 13
+1..1
+not ok 1 - this is fine
+# failed 1 test
+`
diff --git a/tap-snapshots/unit-test.js-TAP-short-output-checks-plan.js b/tap-snapshots/unit-test.js-TAP-short-output-checks-plan.js
new file mode 100644
index 0000000..98d24f7
--- /dev/null
+++ b/tap-snapshots/unit-test.js-TAP-short-output-checks-plan.js
@@ -0,0 +1,5 @@
+'use strict'
+exports[`plan_0`] = `TAP version 13
+1..1
+ok 1 - this is fine
+`
diff --git a/tap-snapshots/unit-test.js-TAP-short-output-checks-sub.js b/tap-snapshots/unit-test.js-TAP-short-output-checks-sub.js
new file mode 100644
index 0000000..646496e
--- /dev/null
+++ b/tap-snapshots/unit-test.js-TAP-short-output-checks-sub.js
@@ -0,0 +1,19 @@
+'use strict'
+exports[`sub_0`] = `TAP version 13
+# Subtest: named child
+ ok 1 - this is fine
+ 1..1
+ok 1 - named child # {time}
+
+# Subtest: named_function
+ 1..1
+ ok 1 - also fine
+ok 2 - named_function # {time}
+
+# Subtest: promisey
+ ok 1 - i promise, it is fine
+ 1..1
+ok 3 - promisey # {time}
+
+1..3
+`
diff --git a/tap-snapshots/unit-test.js-TAP-short-output-checks-todo.js b/tap-snapshots/unit-test.js-TAP-short-output-checks-todo.js
new file mode 100644
index 0000000..f1a9b37
--- /dev/null
+++ b/tap-snapshots/unit-test.js-TAP-short-output-checks-todo.js
@@ -0,0 +1,20 @@
+'use strict'
+exports[`todo_0`] = `TAP version 13
+not ok 1 - i will do this later # TODO
+ ---
+ at:
+ line: 22
+ column: 10
+ file: unit/test.js
+ function: todo
+ source: |
+ tt.fail('i will do this later', { todo: true })
+ ...
+
+ok 2 - i will do this later # TODO
+not ok 3 - this is fine # SKIP
+ok 4 - i did not do this later # SKIP
+1..4
+# todo: 2
+# skip: 2
+`
diff --git a/unit/test.js b/unit/test.js
new file mode 100644
index 0000000..619ae7b
--- /dev/null
+++ b/unit/test.js
@@ -0,0 +1,81 @@
+const t = require('../')
+const Test = t.Test
+
+t.test('short output checks', t => {
+ const cases = {
+ 'no plan': tt => {
+ tt.pass('this is fine')
+ tt.end()
+ },
+
+ 'plan': tt => {
+ tt.plan(1)
+ tt.pass('this is fine')
+ },
+
+ 'comment': tt => {
+ tt.comment('this is fine')
+ tt.end()
+ },
+
+ 'todo': tt => {
+ tt.fail('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.skip('i did not do this later', tt => {
+ throw 'oops'
+ })
+ tt.end()
+ },
+
+ 'no plan fail': tt => {
+ tt.fail('this is fine', { diagnostic: false })
+ tt.end()
+ },
+
+ 'plan fail': tt => {
+ tt.plan(1)
+ tt.fail('this is fine', { diagnostic: false })
+ },
+
+ 'expect fail': tt => {
+ tt.plan(1)
+ tt.fail('this is fine', { expectFail: true })
+ },
+
+ 'sub': tt => {
+ tt.test('named child', { buffered: false }, tt => {
+ tt.pass('this is fine')
+ tt.end()
+ })
+ tt.test({ buffered: false }, function named_function (tt) {
+ tt.plan(1)
+ tt.pass('also fine')
+ })
+ tt.test('promisey', { buffered: false }, tt => new Promise(resolve => {
+ tt.pass('i promise, it is fine')
+ resolve()
+ }))
+ tt.end()
+ },
+ }
+
+ const keys = Object.keys(cases)
+ t.plan(keys.length)
+
+ for (let i in cases) {
+ t.test(i, t => {
+ t.plan(1)
+ const tt = new Test()
+ let out = ''
+ tt.on('data', c => out += c)
+ tt.on('end', _ => {
+ out = out.replace(/ # time=[0-9\.]+m?s\n/g, ' # {time}\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