/
build_spec.js
43 lines (36 loc) · 1.08 KB
/
build_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
require('../spec_helper')
const fs = require(`${lib}/fs`)
const makeUserPackageFile = require('../../scripts/build')
const snapshot = require('../support/snapshot')
const la = require('lazy-ass')
const is = require('check-more-types')
const R = require('ramda')
const hasVersion = (json) => {
return la(is.semver(json.version), 'cannot find version', json)
}
const hasAuthor = (json) => {
return la(json.author === 'Brian Mann', 'wrong author name', json)
}
const changeVersion = R.assoc('version', 'x.y.z')
describe('package.json build', () => {
beforeEach(function () {
// stub package.json in CLI
// with a few test props
// the rest should come from root package.json file
sinon.stub(fs, 'readJsonAsync').resolves({
name: 'test',
engines: 'test engines',
})
sinon.stub(fs, 'outputJsonAsync').resolves()
})
it('author name and version', () => {
return makeUserPackageFile()
.tap(hasAuthor)
.tap(hasVersion)
})
it('outputs expected properties', () => {
return makeUserPackageFile()
.then(changeVersion)
.then(snapshot)
})
})