forked from nodejs/core-validate-commit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli-test.js
44 lines (36 loc) · 1.24 KB
/
cli-test.js
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
'use strict'
const { test } = require('tap')
const { spawn } = require('child_process')
const subsystems = require('../lib/rules/subsystem')
test('Test cli flags', (t) => {
t.test('test list-subsystems', (tt) => {
const ls = spawn('./bin/cmd.js', ['--list-subsystems'])
let compiledData = ''
ls.stdout.on('data', (data) => {
compiledData += data
})
ls.stderr.on('data', (data) => {
tt.fail('This should not happen')
})
ls.on('close', (code) => {
// Get the list of subsytems as an Array.
// Need to match words that also have the "-" in them
const subsystemsFromOutput = compiledData.match(/[\w'-]+/g)
const defaultSubsystems = subsystems.defaults.subsystems
tt.equal(subsystemsFromOutput.length,
defaultSubsystems.length,
'Should have the same length')
// Loop through the output list and compare with the real list
// to make sure they are all there
const missing = []
subsystemsFromOutput.forEach((sub) => {
if (!defaultSubsystems.find((x) => {return x === sub})) {
missing.push(sub)
}
})
tt.equal(missing.length, 0, 'Should have no missing subsystems')
tt.end()
})
})
t.end()
})