-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcliTest.js
More file actions
70 lines (60 loc) · 2.94 KB
/
Copy pathcliTest.js
File metadata and controls
70 lines (60 loc) · 2.94 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
69
70
/* eslint-disable no-undef */
/**
* @file cliTest, contains all the tests.
*
* @author Jose Gracia Berenguer
* @since 1.0.0
* @link https://github.com/Josee9988/Implode-CSS
*/
import assert from 'assert';
import {
parseArgumentsIntoOptions,
} from '../src/cli/cli';
import promptForMissingOptions from '../src/cli/promptCLI';
describe('Exceptions test suite for CLI - arguments', () => {
it('Audit should be true, and the rest should be on their default values', () => {
let rawArguments = ['/usr/local/bin/node', '/usr/local/bin/implodeCss', '-a'];
let received = parseArgumentsIntoOptions(rawArguments);
assert.deepStrictEqual(received.audit, true);
assert.deepStrictEqual(received.defaultOptions, false);
assert.deepStrictEqual(received.fix, false);
assert.deepStrictEqual(received.help, false);
assert.deepStrictEqual(received.version, false);
assert.deepStrictEqual(received.port, 4949);
assert.deepStrictEqual(received.ignore, undefined);
rawArguments = ['/usr/local/bin/node', '/usr/local/bin/implodeCss', '--audit'];
received = parseArgumentsIntoOptions(rawArguments);
assert.deepStrictEqual(received.audit, true);
});
it('Audit should be true, and the rest should be on their default values', () => {
let rawArguments = ['/usr/local/bin/node', '/usr/local/bin/implodeCss', '-f'];
let received = parseArgumentsIntoOptions(rawArguments);
assert.deepStrictEqual(received.fix, true);
assert.deepStrictEqual(received.audit, false);
assert.deepStrictEqual(received.defaultOptions, false);
assert.deepStrictEqual(received.help, false);
assert.deepStrictEqual(received.version, false);
assert.deepStrictEqual(received.port, 4949);
assert.deepStrictEqual(received.ignore, undefined);
rawArguments = ['/usr/local/bin/node', '/usr/local/bin/implodeCss', '--fix'];
received = parseArgumentsIntoOptions(rawArguments);
assert.deepStrictEqual(received.fix, true);
});
it('Folder to implode should be the actual if the user used a: \'.\'', () => {
const actualDirectory = process.cwd();
const rawArguments = ['/usr/local/bin/node', '/usr/local/bin/implodeCss', '.', '-f'];
const received = parseArgumentsIntoOptions(rawArguments);
promptForMissingOptions(received).then((options) => {
assert.deepStrictEqual(options.folderToImplode, actualDirectory);
})
.catch(() => { // if not just fail the test
assert.deepStrictEqual(false, true);
});
});
it('Should use the port given', () => {
const rawArguments = ['/usr/local/bin/node', '/usr/local/bin/implodeCss', '.', '-a', '-p', '9999'];
let received = parseArgumentsIntoOptions(rawArguments);
assert.deepStrictEqual(received.port, 9999);
received = parseArgumentsIntoOptions(rawArguments);
});
});