Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/init-package-json/test/scope-in-config.js')
-rw-r--r--node_modules/init-package-json/test/scope-in-config.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/node_modules/init-package-json/test/scope-in-config.js b/node_modules/init-package-json/test/scope-in-config.js
new file mode 100644
index 000000000..1fa83d9c1
--- /dev/null
+++ b/node_modules/init-package-json/test/scope-in-config.js
@@ -0,0 +1,47 @@
+var fs = require('fs')
+var path = require('path')
+
+var rimraf = require('rimraf')
+var tap = require('tap')
+
+var init = require('../')
+
+var EXPECT = {
+ name: '@scoped/test',
+ version: '1.0.0',
+ description: '',
+ author: '',
+ scripts: { test: 'echo \"Error: no test specified\" && exit 1' },
+ main: 'basic.js',
+ keywords: [],
+ license: 'ISC'
+}
+
+tap.test('--yes with scope', function (t) {
+ init(__dirname, __dirname, { yes: 'yes', scope: '@scoped' }, function (er, data) {
+ if (er) throw er
+
+ t.same(EXPECT, data)
+ t.end()
+ })
+})
+
+var json = {
+ name: '@already/scoped',
+ version: '1.0.0'
+}
+
+tap.test('with existing package.json', function (t) {
+ fs.writeFileSync(path.join(__dirname, 'package.json'), JSON.stringify(json, null, 2))
+ init(__dirname, __dirname, { yes: 'yes', scope: '@still' }, function (er, data) {
+ if (er) throw er
+
+ t.equal(data.name, '@still/scoped', 'new scope is added, basic name is kept')
+ t.end()
+ })
+})
+
+tap.test('teardown', function (t) {
+ rimraf.sync(path.join(__dirname, 'package.json'))
+ t.end()
+})