1 | 'use strict';
|
2 |
|
3 | var tap = require('tap');
|
4 | var tape = require('../');
|
5 | var forEach = require('for-each');
|
6 | var through = require('through');
|
7 |
|
8 | tap.test('object results', function (assert) {
|
9 | var printer = through({ objectMode: true });
|
10 | var objects = [];
|
11 |
|
12 | printer.write = function (obj) {
|
13 | objects.push(obj);
|
14 | };
|
15 |
|
16 | printer.end = function (obj) {
|
17 | if (obj) { objects.push(obj); }
|
18 |
|
19 | var todos = 0;
|
20 | var skips = 0;
|
21 | var testIds = [];
|
22 | var endIds = [];
|
23 | var asserts = 0;
|
24 |
|
25 | assert.equal(objects.length, 13);
|
26 |
|
27 | forEach(objects, function (object) {
|
28 | if (object.type === 'assert') {
|
29 | asserts++;
|
30 | } else if (object.type === 'test') {
|
31 | testIds.push(object.id);
|
32 |
|
33 | if (object.skip) {
|
34 | skips++;
|
35 | } else if (object.todo) {
|
36 | todos++;
|
37 | }
|
38 | } else if (object.type === 'end') {
|
39 | endIds.push(object.text);
|
40 |
|
41 | assert.notEqual(testIds.indexOf(object.test), -1);
|
42 | }
|
43 | });
|
44 |
|
45 | assert.equal(asserts, 5);
|
46 | assert.equal(skips, 1);
|
47 | assert.equal(todos, 2);
|
48 | assert.equal(testIds.length, endIds.length);
|
49 | assert.end();
|
50 | };
|
51 |
|
52 | tape.createStream({ objectMode: true }).pipe(printer);
|
53 |
|
54 | tape('parent', function (t1) {
|
55 | t1.equal(true, true);
|
56 | t1.test('child1', { skip: true }, function (t2) {
|
57 | t2.equal(true, true);
|
58 | t2.equal(true, false);
|
59 | t2.end();
|
60 | });
|
61 | t1.test('child2', { todo: true }, function (t3) {
|
62 | t3.equal(true, false);
|
63 | t3.equal(true, true);
|
64 | t3.end();
|
65 | });
|
66 | t1.test('child3', { todo: true });
|
67 | t1.equal(true, true);
|
68 | t1.equal(true, true);
|
69 | t1.end();
|
70 | });
|
71 | });
|