diff options
Diffstat (limited to 'deps/npm/node_modules/init-package-json/test/basic.js')
-rw-r--r-- | deps/npm/node_modules/init-package-json/test/basic.js | 59 |
1 files changed, 22 insertions, 37 deletions
diff --git a/deps/npm/node_modules/init-package-json/test/basic.js b/deps/npm/node_modules/init-package-json/test/basic.js index 7e3134ee6..f07f435bc 100644 --- a/deps/npm/node_modules/init-package-json/test/basic.js +++ b/deps/npm/node_modules/init-package-json/test/basic.js @@ -1,48 +1,33 @@ -var tap = require('tap') +var common = require('./lib/common') var init = require('../') +var path = require('path') var rimraf = require('rimraf') -var semver = require('semver') +var test = require('tap').test -tap.test('the basics', function (t) { - var i = __dirname + '/basic.input' - var dir = __dirname - init(dir, i, {foo:'bar'}, function (er, data) { +test('the basics', function (t) { + var i = path.join(__dirname, 'basic.input') + init(__dirname, i, { foo: 'bar' }, function (er, data) { if (er) throw er - var expect = - { name: 'the-name', - version: '1.2.5', - description: 'description', - author: 'npmbot <n@p.m> (http://npm.im)', - scripts: { test: 'make test' }, - main: 'main.js', - config: { foo: 'bar' }, - package: {} } + var expect = { + name: 'the-name', + version: '1.2.5', + description: 'description', + author: 'npmbot <n@p.m> (http://npm.im)', + scripts: { test: 'make test' }, + main: 'main.js', + config: { foo: 'bar' }, + package: {} + } t.same(data, expect) t.end() }) - var stdin = process.stdin - var name = 'the-name\n' - var desc = 'description\n' - var yes = 'yes\n' - if (semver.gte(process.versions.node, '0.11.0')) { - ;[name, desc, yes].forEach(function (chunk) { - stdin.push(chunk) - }) - } else { - function input (chunk, ms) { - setTimeout(function () { - stdin.emit('data', chunk) - }, ms) - } - stdin.once('readable', function () { - var ms = 0 - ;[name, desc, yes].forEach(function (chunk) { - input(chunk, ms += 50) - }) - }) - } + common.drive([ + 'the-name\n', + 'description\n', + 'yes\n' + ]) }) -tap.test('teardown', function (t) { +test('teardown', function (t) { rimraf(__dirname + '/package.json', t.end.bind(t)) }) |