From 81df21b924d1a8c7f9a2f872ea795ab9d7b03eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6nnemann?= Date: Wed, 4 Feb 2015 15:22:33 +0100 Subject: [PATCH] test(install): initial scenario --- package.json | 7 +++++-- tests/index.js | 7 +++++++ tests/scenarios/install.js | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 tests/index.js create mode 100644 tests/scenarios/install.js diff --git a/package.json b/package.json index 0c577d55..9f9abb8c 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,11 @@ "devDependencies": { "lodash.defaults": "^3.0.0", "nano-uid": "^0.2.0", + "nixt": "^0.4.1", + "sinopia": "^1.0.0", "standard": "^2.3.1", - "sinopia": "^1.0.0" + "tap-spec": "^2.2.0", + "tape": "^3.5.0" }, "engines": { "node": "^0.10.0", @@ -49,6 +52,6 @@ "posttest": "./bin/post-test", "prepublish": "./bin/semantic-release pre", "pretest": "./bin/pre-test", - "test": "standard" + "test": "standard && node tests | tap-spec" } } diff --git a/tests/index.js b/tests/index.js new file mode 100644 index 00000000..e101a3d6 --- /dev/null +++ b/tests/index.js @@ -0,0 +1,7 @@ +'use strict' + +var test = require('tape') + +var createModule = require('./lib/create-module') + +require('./scenarios/install')(test, createModule) diff --git a/tests/scenarios/install.js b/tests/scenarios/install.js new file mode 100644 index 00000000..f6c48071 --- /dev/null +++ b/tests/scenarios/install.js @@ -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') + }) + }) + } + })) +}