-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.js
57 lines (50 loc) · 1.39 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
// @flow
'use strict';
const test = require('ava');
const { collectImportsSync } = require('./');
const fixtures = require('fixturez');
const { join } = require('path');
const f = fixtures(__dirname, { root: __dirname });
let nonePath = f.find('none.js');
let externalPath = f.find('external.js');
let internalPath = f.find('internal.js');
let internalAndExternalPath = f.find('internal-and-external.js');
let exportFromPath = f.find('export-from.js');
let cycleAPath = f.find('cycle-a.js');
let cycleBPath = f.find('cycle-b.js');
test('none', t => {
t.deepEqual(collectImportsSync(nonePath), {
internal: [nonePath],
external: [],
});
});
test('external', t => {
t.deepEqual(collectImportsSync(externalPath), {
internal: [externalPath],
external: ['external'],
});
});
test('internal', t => {
t.deepEqual(collectImportsSync(internalPath), {
internal: [internalPath, nonePath],
external: [],
});
});
test('internal-and-external', t => {
t.deepEqual(collectImportsSync(internalAndExternalPath), {
internal: [internalAndExternalPath, externalPath],
external: ['external'],
});
});
test('export-from', t => {
t.deepEqual(collectImportsSync(exportFromPath), {
internal: [exportFromPath, nonePath],
external: [],
});
});
test('cycle', t => {
t.deepEqual(collectImportsSync(cycleAPath), {
internal: [cycleAPath, cycleBPath],
external: [],
});
});