-
Notifications
You must be signed in to change notification settings - Fork 27
/
as-parent-spec.js
73 lines (64 loc) · 1.7 KB
/
as-parent-spec.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
68
69
70
71
72
73
const path = require('path')
const chdir = require('chdir-promise')
const nextUpdate = require('..')
const execa = require('execa')
const snapShot = require('snap-shot')
const _ = require('lodash')
const is = require('check-more-types')
const la = require('lazy-ass')
const TWO_MINUTES = 120000
const testFolder = path.join(__dirname, 'test-next-updater')
function prune () {
return execa.shell('npm prune')
}
function install () {
return execa.shell('npm install')
}
/* global describe, beforeEach, afterEach, it */
describe('testing check-types', () => {
beforeEach(function () {
this.timeout(TWO_MINUTES)
return chdir.to(testFolder)
.then(prune)
.then(install)
})
afterEach(function () {
this.timeout(TWO_MINUTES)
return chdir.to(testFolder)
.then(prune)
.then(install)
.then(chdir.back)
})
it('checks latest check-types', function () {
this.timeout(TWO_MINUTES)
const opts = {
module: 'check-types',
latest: true,
keep: false
}
const removeVersions = (results) => results.map(r => {
la(is.semver(r.version), 'expected version', r)
r.version = 'valid'
return r
})
return snapShot(nextUpdate(opts)
.then(_.flatten)
.then(removeVersions)
)
})
it('checks some versions of check-types', function () {
this.timeout(TWO_MINUTES)
const limit = (name, version) => {
if (name === 'check-types' && version.startsWith('0.7')) {
return true
}
return false
}
const opts = {
module: 'check-types',
keep: false,
limit
}
return snapShot(nextUpdate(opts))
})
})