forked from okunishinishi/node-install-if-needed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
57 lines (49 loc) · 1.52 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
/**
* Test
*/
'use strict'
const fs = require('fs')
const lib = require('./lib')
const index = require('./index')
const { equal, ok, doesNotReject } = require('assert').strict
describe('Install if needed', async function () {
this.timeout(40 * 1000)
it('has index', ()=> {
ok(index)
})
it('Install mock dir', async () => {
await lib({
cwd: `${__dirname}/misc/mocks/mock-pack01`,
})
const wasInstalled = await lib({
cwd: `${__dirname}/misc/mocks/mock-pack01`,
})
ok(!wasInstalled)
})
it('Install mock dir2: locale file dependency', async () => {
await lib({
cwd: `${__dirname}/misc/mocks/mock-pack02`,
})
const wasInstalled = await lib({
cwd: `${__dirname}/misc/mocks/mock-pack02`,
})
ok(!wasInstalled)
await doesNotReject(() => fs.promises.stat(`${__dirname}/misc/mocks/mock-pack02/node_modules/mock-pack01`))
})
it('Install mock dir3: npm-install-if-needed が上のパッケージでインストールされているときにも正しく解決する', async () => {
await lib({
cwd: `${__dirname}/misc/mocks/mock-pack03`,
})
const wasInstalled = await lib({
cwd: `${__dirname}/misc/mocks/mock-pack03`,
})
ok(!wasInstalled)
})
it('Install mock dir4: npm install if node_modules are not found', async () => {
await lib({
cwd: `${__dirname}/misc/mocks/mock-pack04`,
})
await doesNotReject(() => fs.promises.stat(`${__dirname}/misc/mocks/mock-pack04/npm-install-done`))
})
})
/* global describe, it */