-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
Copy pathcheck.js
68 lines (57 loc) · 1.81 KB
/
check.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* @flow */
import type {CLIFunctionReturn} from '../../src/types.js';
import * as reporters from '../../src/reporters/index.js';
import * as checkCmd from '../../src/cli/commands/check.js';
import {run as buildRun} from './_helpers.js';
import assert from 'assert';
const path = require('path');
const fixturesLoc = path.join(__dirname, '..', 'fixtures', 'check');
const runCheck = buildRun.bind(
null,
reporters.ConsoleReporter,
fixturesLoc,
(args, flags, config, reporter): CLIFunctionReturn => {
return checkCmd.run(config, reporter, flags, args);
},
);
test('--verify-tree should report wrong version ', async (): Promise<void> => {
let thrown = false;
try {
await runCheck([], {verifyTree: true}, 'verify-tree-version-mismatch');
} catch (e) {
thrown = true;
}
assert(thrown);
});
test('--verify-tree should report missing dependency ',
async (): Promise<void> => {
let thrown = false;
try {
await runCheck([], {verifyTree: true}, 'verify-tree-not-found');
} catch (e) {
thrown = true;
}
assert(thrown);
});
test('--verify-tree should pass on hoisted dependency ',
async (): Promise<void> => {
await runCheck([], {verifyTree: true}, 'verify-tree-hoisted');
});
test('--verify-tree should check dev dependencies ',
async (): Promise<void> => {
let thrown = false;
try {
await runCheck([], {verifyTree: true}, 'verify-tree-dev');
} catch (e) {
thrown = true;
}
assert(thrown);
});
test('--verify-tree should check skip dev dependencies if --production flag passed',
async (): Promise<void> => {
await runCheck([], {verifyTree: true, production: true}, 'verify-tree-dev-prod');
});
test('--verify-tree should check skip deeper dev dependencies',
async (): Promise<void> => {
await runCheck([], {verifyTree: true, production: true}, 'verify-tree-dev-deep');
});