From 89f19287693a7d9af88ae9c107e3dec8e6f5fe87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6nnemann?= Date: Thu, 5 Feb 2015 01:33:50 +0100 Subject: [PATCH] test(publish): initial scenario --- tests/index.js | 1 + tests/scenarios/publish.js | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/scenarios/publish.js diff --git a/tests/index.js b/tests/index.js index 52b0a38d..bd3b13c1 100644 --- a/tests/index.js +++ b/tests/index.js @@ -7,3 +7,4 @@ var createModule = require('./lib/create-module') require('./scenarios/install')(test, createModule) require('./scenarios/prepublish')(test, createModule) require('./scenarios/postpublish')(test, createModule) +require('./scenarios/publish')(test, createModule) diff --git a/tests/scenarios/publish.js b/tests/scenarios/publish.js new file mode 100644 index 00000000..499a74ee --- /dev/null +++ b/tests/scenarios/publish.js @@ -0,0 +1,37 @@ +'use strict' + +var efh = require('error-first-handler') +var nixt = require('nixt') + +module.exports = function (test, createModule) { + test('publish', function (t) { + publishTest(t, 'npm publish', 'pre and post hooks work as a part of publish') + publishTest(t, 'npm pub', 'pre and post hooks work as a part of publish with abbrevd command') + + function publishTest (t, command, testname, last) { + createModule({ + repository: { + type: 'git', + url: 'http://github.com/user/repo' + } + }, efh()(function (name, cwd) { + t.test(testname, function (t) { + t.plan(1) + + nixt() + .cwd(cwd) + .env('CI', true) + .env('GH_URL', 'http://127.0.0.1:4343/') + .env('GH_TOKEN', '***') + .exec('git commit --allow-empty -m "feat: super"') + .run(command) + .code(1) + .stdout(/Everything is alright/) + .end(function(err) { + t.error(err, 'nixt') + }) + }) + })) + } + }) +}