test: convert from tape to tap

This commit is contained in:
Stephan Bönnemann 2015-06-11 17:07:09 -07:00
parent 649af78c56
commit 4e90e4b98b
11 changed files with 241 additions and 273 deletions

View File

@ -31,8 +31,7 @@
"nock": "^2.2.0", "nock": "^2.2.0",
"sinopia": "^1.0.0", "sinopia": "^1.0.0",
"standard": "^4.0.1", "standard": "^4.0.1",
"tap-spec": "^4.0.0", "tap": "^1.2.0"
"tape": "^4.0.0"
}, },
"engines": { "engines": {
"iojs": "^1", "iojs": "^1",
@ -69,7 +68,7 @@
"prepublish": "npm run build && ./bin/semantic-release.js pre", "prepublish": "npm run build && ./bin/semantic-release.js pre",
"pretest": "npm run build", "pretest": "npm run build",
"test": "./bin/test", "test": "./bin/test",
"test:integration": "node tests | tap-spec", "test:integration": "tap tests/{scenarios,tap}/*.js",
"test:style": "standard" "test:style": "standard"
} }
} }

View File

@ -1,11 +0,0 @@
'use strict'
require('./tap/npm-info')()
require('./scenarios/custom-analyzer')()
require('./scenarios/custom-verification')()
require('./scenarios/ignore')()
require('./scenarios/prepublish')()
require('./scenarios/postpublish')()
require('./scenarios/publish')()
require('./scenarios/verify')()
require('./scenarios/setup')()

View File

@ -3,23 +3,21 @@
var path = require('path') var path = require('path')
var efh = require('error-first-handler') var efh = require('error-first-handler')
var test = require('tape') var test = require('tap').test
var createModule = require('../lib/create-module') var createModule = require('../lib/create-module')
var commitToVersionTest = require('../lib/commit-to-version-test') var commitToVersionTest = require('../lib/commit-to-version-test')
module.exports = function () { test('custom-analyzer', function (t) {
createModule({ createModule({
release: { release: {
analyzer: path.join(__dirname, '../lib/custom-analyzer') analyzer: path.join(__dirname, '../lib/custom-analyzer')
} }
}, efh()(function (name, cwd) { }, efh()(function (name, cwd) {
test('custom-analyzer', function (t) {
commitToVersionTest(t, 'HO', '0.0.0', 1, 'abort publish w/o changes', cwd) commitToVersionTest(t, 'HO', '0.0.0', 1, 'abort publish w/o changes', cwd)
commitToVersionTest(t, 'BAZ', '1.0.0', 0, 'release 1.0.0 if unpublished', cwd) commitToVersionTest(t, 'BAZ', '1.0.0', 0, 'release 1.0.0 if unpublished', cwd)
commitToVersionTest(t, 'BAZ', '1.0.1', 0, 'bump patch for fix', cwd) commitToVersionTest(t, 'BAZ', '1.0.1', 0, 'bump patch for fix', cwd)
commitToVersionTest(t, 'BAR', '1.1.0', 0, 'bump minor for feature', cwd) commitToVersionTest(t, 'BAR', '1.1.0', 0, 'bump minor for feature', cwd)
commitToVersionTest(t, 'FOO', '2.0.0', 0, 'bump major for breaking change', cwd) commitToVersionTest(t, 'FOO', '2.0.0', 0, 'bump major for breaking change', cwd)
})
})) }))
} })

View File

@ -4,17 +4,16 @@ var path = require('path')
var efh = require('error-first-handler') var efh = require('error-first-handler')
var nixt = require('nixt') var nixt = require('nixt')
var test = require('tape') var test = require('tap').test
var createModule = require('../lib/create-module') var createModule = require('../lib/create-module')
module.exports = function () { test('custom-verification', function (t) {
createModule({ createModule({
release: { release: {
verification: path.join(__dirname, '../lib/custom-verification') verification: path.join(__dirname, '../lib/custom-verification')
} }
}, efh()(function (name, cwd) { }, efh()(function (name, cwd) {
test('custom-verification', function (t) {
t.test('even commit count', function (t) { t.test('even commit count', function (t) {
t.plan(1) t.plan(1)
nixt() nixt()
@ -43,6 +42,5 @@ module.exports = function () {
t.error(err, 'nixt') t.error(err, 'nixt')
}) })
}) })
})
})) }))
} })

View File

@ -4,22 +4,22 @@ var fs = require('fs')
var efh = require('error-first-handler') var efh = require('error-first-handler')
var nixt = require('nixt') var nixt = require('nixt')
var test = require('tape') var test = require('tap').test
var createModule = require('../lib/create-module') var createModule = require('../lib/create-module')
module.exports = function () {
createModule(efh()(function (name, cwd) {
test('ignore', function (t) { test('ignore', function (t) {
ignoreTest(t, 'npm install', 'not doing anything when the module is installed') createModule(efh()(function (name, cwd) {
ignoreTest(t, 'npm i', 'not doing anything when the module is installed with abbrevd command') ignoreTest(t, cwd, 'npm install', 'not doing anything when the module is installed')
ignoreTest(t, 'npm link', 'not doing anything when the module is linked') ignoreTest(t, cwd, 'npm i', 'not doing anything when the module is installed with abbrevd command')
ignoreTest(t, 'npm lin', 'not doing anything when the module is linked with abbrevd command') ignoreTest(t, cwd, 'npm link', 'not doing anything when the module is linked')
ignoreTest(t, 'npm pack', 'not doing anything when the module is packed') ignoreTest(t, cwd, 'npm lin', 'not doing anything when the module is linked with abbrevd command')
ignoreTest(t, 'npm pa', 'not doing anything when the module is packed with abbrevd command') ignoreTest(t, cwd, 'npm pack', 'not doing anything when the module is packed')
ignoreTest(t, cwd, 'npm pa', 'not doing anything when the module is packed with abbrevd command')
}))
}) })
function ignoreTest (t, command, name, last) { function ignoreTest (t, cwd, command, name) {
t.test(name, function (t) { t.test(name, function (t) {
t.plan(2) t.plan(2)
@ -36,5 +36,3 @@ module.exports = function () {
}) })
}) })
} }
}))
}

View File

@ -5,7 +5,7 @@ var path = require('path')
var efh = require('error-first-handler') var efh = require('error-first-handler')
var GitHubApi = require('github') var GitHubApi = require('github')
var nixt = require('nixt') var nixt = require('nixt')
var test = require('tape') var test = require('tap').test
var createModule = require('../lib/create-module') var createModule = require('../lib/create-module')
@ -21,7 +21,7 @@ github.authenticate({
token: '***' token: '***'
}) })
module.exports = function () { test('postpublish', function (t) {
createModule({ createModule({
version: '2.0.0', version: '2.0.0',
repository: { repository: {
@ -29,7 +29,6 @@ module.exports = function () {
url: 'http://github.com/user/repo' url: 'http://github.com/user/repo'
} }
}, efh()(function (name, cwd) { }, efh()(function (name, cwd) {
test('postpublish', function (t) {
var base = getBase(cwd) var base = getBase(cwd)
t.test('publish new version to github releases', function (t) { t.test('publish new version to github releases', function (t) {
@ -66,7 +65,6 @@ module.exports = function () {
t.ok(/\n\n\n#### Features\n\n\* \*\*cool:\*\*\n.*the next big thing/.test(res.body), 'body') t.ok(/\n\n\n#### Features\n\n\* \*\*cool:\*\*\n.*the next big thing/.test(res.body), 'body')
}) })
}) })
})
})) }))
createModule({ createModule({
@ -79,7 +77,6 @@ module.exports = function () {
notes: path.join(__dirname, '../lib/custom-release-notes') notes: path.join(__dirname, '../lib/custom-release-notes')
} }
}, efh()(function (name, cwd) { }, efh()(function (name, cwd) {
test('custom-release-notes', function (t) {
var base = getBase(cwd) var base = getBase(cwd)
t.test('publish new version (with custom notes) to github releases', function (t) { t.test('publish new version (with custom notes) to github releases', function (t) {
@ -103,9 +100,8 @@ module.exports = function () {
t.ok(/custom log/.test(res.body), 'body') t.ok(/custom log/.test(res.body), 'body')
}) })
}) })
})
})) }))
} })
function getBase (cwd) { function getBase (cwd) {
return nixt() return nixt()

View File

@ -1,19 +1,17 @@
'use strict' 'use strict'
var efh = require('error-first-handler') var efh = require('error-first-handler')
var test = require('tape') var test = require('tap').test
var createModule = require('../lib/create-module') var createModule = require('../lib/create-module')
var commitToVersionTest = require('../lib/commit-to-version-test') var commitToVersionTest = require('../lib/commit-to-version-test')
module.exports = function () {
createModule(efh()(function (name, cwd) {
test('prepublish', function (t) { test('prepublish', function (t) {
createModule(efh()(function (name, cwd) {
commitToVersionTest(t, 'refactor: change', '0.0.0', 1, 'abort publish w/o changes', cwd) commitToVersionTest(t, 'refactor: change', '0.0.0', 1, 'abort publish w/o changes', cwd)
commitToVersionTest(t, 'fix: change', '1.0.0', 0, 'release 1.0.0 if unpublished', cwd) commitToVersionTest(t, 'fix: change', '1.0.0', 0, 'release 1.0.0 if unpublished', cwd)
commitToVersionTest(t, 'fix: change', '1.0.1', 0, 'bump patch for fix', cwd) commitToVersionTest(t, 'fix: change', '1.0.1', 0, 'bump patch for fix', cwd)
commitToVersionTest(t, 'feat: change', '1.1.0', 0, 'bump minor for feature', cwd) commitToVersionTest(t, 'feat: change', '1.1.0', 0, 'bump minor for feature', cwd)
commitToVersionTest(t, 'fix: BREAKING CHANGE: change', '2.0.0', 0, 'bump major for breaking change', cwd) commitToVersionTest(t, 'fix: BREAKING CHANGE: change', '2.0.0', 0, 'bump major for breaking change', cwd)
})
})) }))
} })

View File

@ -2,11 +2,10 @@
var efh = require('error-first-handler') var efh = require('error-first-handler')
var nixt = require('nixt') var nixt = require('nixt')
var test = require('tape') var test = require('tap').test
var createModule = require('../lib/create-module') var createModule = require('../lib/create-module')
module.exports = function () {
test('publish', function (t) { test('publish', function (t) {
publishTest(t, 'npm publish', 'pre and post hooks work as a part of publish') 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') publishTest(t, 'npm pub', 'pre and post hooks work as a part of publish with abbrevd command')
@ -37,4 +36,3 @@ module.exports = function () {
})) }))
} }
}) })
}

View File

@ -5,18 +5,17 @@ var readFile = require('fs').readFileSync
var efh = require('error-first-handler') var efh = require('error-first-handler')
var nixt = require('nixt') var nixt = require('nixt')
var test = require('tape') var test = require('tap').test
var createModule = require('../lib/create-module') var createModule = require('../lib/create-module')
module.exports = function () { test('setup', function (t) {
createModule({ createModule({
repository: {}, repository: {},
scripts: { scripts: {
postpublish: 'npm run gh-pages' postpublish: 'npm run gh-pages'
} }
}, efh()(function (name, cwd) { }, efh()(function (name, cwd) {
test('setup', function (t) {
t.test('setup "package.json"', function (t) { t.test('setup "package.json"', function (t) {
t.plan(5) t.plan(5)
@ -36,6 +35,5 @@ module.exports = function () {
t.is(pkg.scripts.postpublish, 'npm run gh-pages && semantic-release post', 'post') t.is(pkg.scripts.postpublish, 'npm run gh-pages && semantic-release post', 'post')
}) })
}) })
})
})) }))
} })

View File

@ -2,16 +2,15 @@
var efh = require('error-first-handler') var efh = require('error-first-handler')
var nixt = require('nixt') var nixt = require('nixt')
var test = require('tape') var test = require('tap').test
var createModule = require('../lib/create-module') var createModule = require('../lib/create-module')
module.exports = function () {
test('verify', function (t) { test('verify', function (t) {
createModule({ createModule({
repository: {}, repository: {},
scripts: { scripts: {
prepublish: '../../../bin/semantic-release.js pre' prepublish: '../../../bin/semantic-release.js pre --no-token'
} }
}, efh()(function (name, cwd) { }, efh()(function (name, cwd) {
t.test('verify package and options before publishing', function (t) { t.test('verify package and options before publishing', function (t) {
@ -50,4 +49,3 @@ module.exports = function () {
}) })
})) }))
}) })
}

View File

@ -1,6 +1,6 @@
'use strict' 'use strict'
var test = require('tape') var test = require('tap').test
var nock = require('nock') var nock = require('nock')
var npmInfo = require('../../dist/lib/npm-info.js') var npmInfo = require('../../dist/lib/npm-info.js')
@ -20,7 +20,6 @@ var defaultModule = {
process.env.npm_config_registry = registry process.env.npm_config_registry = registry
module.exports = function () {
test('npm-info', function (t) { test('npm-info', function (t) {
var regMock = nock(registry, { var regMock = nock(registry, {
reqheaders: { reqheaders: {
@ -50,4 +49,3 @@ module.exports = function () {
}) })
}) })
}) })
}