-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathhelp.test.js
More file actions
68 lines (57 loc) · 1.56 KB
/
help.test.js
File metadata and controls
68 lines (57 loc) · 1.56 KB
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
// Copyright IBM Corp. 2016,2019. All Rights Reserved.
// Node module: loopback-cli
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT
'use strict';
const expect = require('./helpers/expect');
const fs = require('fs');
const invoke = require('./helpers/invoke');
const mkdirp = require('mkdirp');
const path = require('path');
const sandbox = require('./helpers/sandbox');
const COMMANDS = [
'',
'acl',
'bluemix',
'boot-script',
'datasource',
'export-api-def',
'middleware',
'model',
'oracle',
'property',
'relation',
'remote-method',
'soap',
'swagger',
'zosconnectee',
];
const FIXTURES = path.resolve(__dirname, 'fixtures');
const OUT_FIXTURES = path.join(FIXTURES, 'actual');
describe('help', () => {
beforeEach(sandbox.reset);
before(createFixtureOutputDir);
COMMANDS.forEach(cmd => {
const args = [];
if (cmd) args.push(cmd);
args.push('--help');
const fullCmd = ['lb'].concat(args);
it('prints help for "lb ' + args.join(' ') + '"', () => {
return invoke(args).then(result => {
let helpFile = 'help-lb';
if (cmd) helpFile += '-' + cmd;
helpFile += '.txt';
const actual = result.stdout;
fs.writeFileSync(path.resolve(OUT_FIXTURES, helpFile), actual, 'utf-8');
const expected = fs.readFileSync(
path.resolve(FIXTURES, helpFile),
'utf-8'
);
expect(actual).to.equal(expected);
});
});
});
function createFixtureOutputDir() {
mkdirp.sync(OUT_FIXTURES);
}
});