Skip to content

Commit

Permalink
fix(test): add test for install --save
Browse files Browse the repository at this point in the history
  • Loading branch information
watilde committed Aug 12, 2017
1 parent bdfb743 commit 679b21b
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/11-install-save.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const fs = require('fs')
const path = require('path')
const exec = require('child_process').exec
const tree = require('strong-npm-ls')
const test = require('tap').test
const bin = path.join(__dirname, '..', 'bin', 'dep.js')
const pkg = path.join(__dirname, 'deps/registry')
const pkgJSON = require(path.join(pkg, 'package.json'))


test((t) => {
exec(`node ${bin} install --save=prod text-table`, {cwd: pkg}, (err, stdout, stderr) => {
t.ifError(err, `${pkgJSON.name}: install ran without error`)
tree.read(pkg, (err, out) => {
t.ifError(err, `${pkgJSON.name}: tree could be read`)
const deps = out.dependencies
t.ok(deps['text-table'], `${pkgJSON.name}: deps are installed`)
t.end()
})
})
})

test((t) => {
exec(`node ${bin} install --save=dev quack-array`, {cwd: pkg}, (err, stdout, stderr) => {
t.ifError(err, `${pkgJSON.name}: install ran without error`)
tree.read(pkg, (err, out) => {
t.ifError(err, `${pkgJSON.name}: tree could be read`)
const deps = out.devDependencies
t.ok(deps['quack-array'], `${pkgJSON.name}: deps are installed`)
t.end()
})
})
})


test((t) => {
var data = pkgJSON
delete data.dependencies['text-table']
delete data.devDependencies
fs.writeFileSync(path.join(pkg, 'package.json'), JSON.stringify(data, 2, 2) + '\n')
t.end()
})

0 comments on commit 679b21b

Please sign in to comment.