summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/init-package-json/test/scope.js
blob: 4fa0649282b7d0ab126cedc41323386dd8a2d473 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var tap = require('tap')
var init = require('../')
var rimraf = require('rimraf')

var EXPECT = {
    name: '@foo/test',
    version: '1.2.5',
    description: 'description',
    author: 'npmbot <n@p.m> (http://npm.im)',
    scripts: { test: 'make test' },
    main: 'main.js',
    config: { scope: '@foo' },
    package: {}
}

tap.test('the scope', function (t) {
  var i = __dirname + '/basic.input'
  var dir = __dirname
  init(dir, i, {scope: '@foo'}, function (er, data) {
    if (er) throw er

    console.log('')
    t.has(data, EXPECT)
    t.end()
  })
  setTimeout(function () {
    process.stdin.emit('data', '@foo/test\n')
  }, 50)
  setTimeout(function () {
    process.stdin.emit('data', 'description\n')
  }, 100)
  setTimeout(function () {
    process.stdin.emit('data', 'yes\n')
  }, 150)
})

tap.test('teardown', function (t) {
  rimraf(__dirname + '/package.json', t.end.bind(t))
})