File: stdin.js

package info (click to toggle)
node-tap 12.0.1+ds-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,916 kB
  • sloc: makefile: 84; sh: 75
file content (82 lines) | stat: -rw-r--r-- 1,367 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const t = require('../')
const Stdin = require('../lib/stdin.js')
const MP = require('stream').PassThrough

process.env.TAP_BAIL = ''
process.env.TAP_BUFFER = ''

t.test('uses stdin if no stream provided', t => {
  const s = new Stdin()
  t.equal(s.stream, process.stdin)
  t.equal(s.name, '/dev/stdin')
  t.end()
})

t.test('basic test', t => {
  const stream = new MP()
  const s = new Stdin({
    tapStream: stream,
    name: 'foo',
    buffered: true
  })
  t.equal(s.stream, stream)
  t.equal(s.name, 'foo')

  s.main(_ => {
    t.match(s.results, {
      ok: true,
      count: 1,
      pass: 1,
      fail: 0,
      bailout: false,
      plan: {
        start: 1,
        end: 1,
        skipAll: false
      },
      failures: []
    })
    t.end()
  })

  s.stream.end(`TAP version 13
1..1
ok 1 - this is fine
`)
})

t.test('failure test', t => {
  const stream = new MP()
  const s = new Stdin({
    tapStream: stream
  })

  s.main(_ => {
    t.match(s.results, {
      ok: false,
      count: 2,
      pass: 1,
      fail: 1,
      bailout: false,
      todo: 0,
      skip: 0,
      plan: {
        start: 1,
        end: 2,
        skipAll: false
      },
      failures: [{
        ok: false,
        id: 2,
        name: 'oops'
      }]
    })
    t.end()
  })

  s.stream.write(`TAP version 13
ok 1 - this is fine
`)

  s.threw(new Error('oops'))
})