test(install): initial scenario

This commit is contained in:
Stephan Bönnemann 2015-02-04 15:22:33 +01:00
parent d22b98a4ee
commit 81df21b924
3 changed files with 45 additions and 2 deletions

View File

@ -21,8 +21,11 @@
"devDependencies": { "devDependencies": {
"lodash.defaults": "^3.0.0", "lodash.defaults": "^3.0.0",
"nano-uid": "^0.2.0", "nano-uid": "^0.2.0",
"nixt": "^0.4.1",
"sinopia": "^1.0.0",
"standard": "^2.3.1", "standard": "^2.3.1",
"sinopia": "^1.0.0" "tap-spec": "^2.2.0",
"tape": "^3.5.0"
}, },
"engines": { "engines": {
"node": "^0.10.0", "node": "^0.10.0",
@ -49,6 +52,6 @@
"posttest": "./bin/post-test", "posttest": "./bin/post-test",
"prepublish": "./bin/semantic-release pre", "prepublish": "./bin/semantic-release pre",
"pretest": "./bin/pre-test", "pretest": "./bin/pre-test",
"test": "standard" "test": "standard && node tests | tap-spec"
} }
} }

7
tests/index.js Normal file
View File

@ -0,0 +1,7 @@
'use strict'
var test = require('tape')
var createModule = require('./lib/create-module')
require('./scenarios/install')(test, createModule)

View File

@ -0,0 +1,33 @@
'use strict'
var fs = require('fs')
var efh = require('error-first-handler')
var nixt = require('nixt')
module.exports = function (test, createModule) {
createModule(efh()(function (name, cwd) {
test('install', function (t) {
installTest(t, 'npm install', 'not doing anything when the module is installed')
installTest(t, 'npm i', 'not doing anything when the module is installed with abbrevd command')
})
function installTest (t, command, name, last) {
t.test(name, function (t) {
t.plan(2)
var pkg = fs.readFileSync(cwd + '/package.json')
nixt()
.cwd(cwd)
.run(command)
.code(0)
.stdout(/> semantic-release pre\n$/m)
.end(function(err) {
t.is(pkg + '', fs.readFileSync(cwd + '/package.json') + '', 'package')
t.error(err, 'nixt')
})
})
}
}))
}