1 | 'use strict';
|
2 |
|
3 | var _chai = require('chai');
|
4 |
|
5 | var _yargs = require('yargs');
|
6 |
|
7 | var _yargs2 = _interopRequireDefault(_yargs);
|
8 |
|
9 | var _sandbox = require('dist/utilities/testHelpers/sandbox');
|
10 |
|
11 | var _sandbox2 = _interopRequireDefault(_sandbox);
|
12 |
|
13 | var _index = require('./index');
|
14 |
|
15 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16 |
|
17 | describe('dev-toolkit', function () {
|
18 | describe('outputs current version', function () {
|
19 | it('when given `-v` argument', function () {
|
20 | _sandbox2.default.spy(console, 'log');
|
21 | (0, _index.devToolkit)({ cmdArgs: ['dev-toolkit', '-v'], runCommand: function runCommand() {} });
|
22 | (0, _chai.expect)(console.log.calledOnce).to.equal(true);
|
23 | });
|
24 | it('when given `--version` argument', function () {
|
25 | _sandbox2.default.spy(console, 'log');
|
26 | (0, _index.devToolkit)({ cmdArgs: ['dev-toolkit', '--version'], runCommand: function runCommand() {} });
|
27 | (0, _chai.expect)(console.log.calledOnce).to.equal(true);
|
28 | });
|
29 | });
|
30 |
|
31 | describe('runs the watch script', function () {
|
32 | var processedArgs = _yargs2.default.alias('w', 'watch').parse(['dev-toolkit', '-w']);
|
33 | var expectedOutput = {
|
34 | script: 'watch',
|
35 | message: 'Watching files for development',
|
36 | args: [processedArgs.watch]
|
37 | };
|
38 |
|
39 | it('when given `-w` argument', function () {
|
40 | var runCommand = _sandbox2.default.spy();
|
41 |
|
42 | (0, _index.devToolkit)({ cmdArgs: ['dev-toolkit', '-w'], runCommand: runCommand });
|
43 | (0, _chai.expect)(runCommand.calledWith(expectedOutput)).to.equal(true);
|
44 | });
|
45 | it('when given `--watch` argument', function () {
|
46 | var runCommand = _sandbox2.default.spy();
|
47 |
|
48 | (0, _index.devToolkit)({ cmdArgs: ['dev-toolkit', '--watch'], runCommand: runCommand });
|
49 | (0, _chai.expect)(runCommand.calledWith(expectedOutput)).to.equal(true);
|
50 | });
|
51 | });
|
52 |
|
53 | describe('runs the serve script', function () {
|
54 | var processedArgs = _yargs2.default.alias('s', 'serve').parse(['dev-toolkit', '-s']);
|
55 | var expectedOutput = {
|
56 | script: 'serve',
|
57 | message: 'Watching files for development',
|
58 | args: [processedArgs.serve]
|
59 | };
|
60 |
|
61 | it('when given `-s` argument', function () {
|
62 | var runCommand = _sandbox2.default.spy();
|
63 |
|
64 | (0, _index.devToolkit)({ cmdArgs: ['dev-toolkit', '-s'], runCommand: runCommand });
|
65 | (0, _chai.expect)(runCommand.calledWith(expectedOutput)).to.equal(true);
|
66 | });
|
67 | it('when given `--serve` argument', function () {
|
68 | var runCommand = _sandbox2.default.spy();
|
69 |
|
70 | (0, _index.devToolkit)({ cmdArgs: ['dev-toolkit', '--serve'], runCommand: runCommand });
|
71 | (0, _chai.expect)(runCommand.calledWith(expectedOutput)).to.equal(true);
|
72 | });
|
73 | });
|
74 |
|
75 | describe('runs the serveStatic script', function () {
|
76 | var processedArgs = _yargs2.default.alias('static', 'serve-static').parse(['dev-toolkit', '--static']);
|
77 | var expectedOutput = {
|
78 | script: 'serveStatic',
|
79 | message: 'Serving the /build folder using a minimal server',
|
80 | args: [processedArgs['serve-static']]
|
81 | };
|
82 |
|
83 | it('when given `--static` argument', function () {
|
84 | var runCommand = _sandbox2.default.spy();
|
85 |
|
86 | (0, _index.devToolkit)({ cmdArgs: ['dev-toolkit', '--static'], runCommand: runCommand });
|
87 | (0, _chai.expect)(runCommand.calledWith(expectedOutput)).to.equal(true);
|
88 | });
|
89 | it('when given `--serve-static` argument', function () {
|
90 | var runCommand = _sandbox2.default.spy();
|
91 |
|
92 | (0, _index.devToolkit)({ cmdArgs: ['dev-toolkit', '--serve-static'], runCommand: runCommand });
|
93 | (0, _chai.expect)(runCommand.calledWith(expectedOutput)).to.equal(true);
|
94 | });
|
95 | });
|
96 |
|
97 | describe('runs the init script', function () {
|
98 | var processedArgs = _yargs2.default.alias('i', 'init').parse(['dev-toolkit', '-i']);
|
99 | var expectedOutput = {
|
100 | script: 'init',
|
101 | message: 'Initializing new project',
|
102 | args: [processedArgs.init]
|
103 | };
|
104 |
|
105 | it('when given `-i` argument', function () {
|
106 | var runCommand = _sandbox2.default.spy();
|
107 |
|
108 | (0, _index.devToolkit)({ cmdArgs: ['dev-toolkit', '-i'], runCommand: runCommand });
|
109 | (0, _chai.expect)(runCommand.calledWith(expectedOutput)).to.equal(true);
|
110 | });
|
111 | it('when given `--init` argument', function () {
|
112 | var runCommand = _sandbox2.default.spy();
|
113 |
|
114 | (0, _index.devToolkit)({ cmdArgs: ['dev-toolkit', '--init'], runCommand: runCommand });
|
115 | (0, _chai.expect)(runCommand.calledWith(expectedOutput)).to.equal(true);
|
116 | });
|
117 | });
|
118 | }); |
\ | No newline at end of file |