npm: Upgrade to 1.3.17
[platform/upstream/nodejs.git] / deps / npm / node_modules / npmconf / test / builtin.js
1 var test = require('tap').test
2 var npmconf = require('../npmconf.js')
3 var common = require('./00-setup.js')
4
5 var ucData =
6   { globalconfig: common.globalconfig,
7     email: 'i@izs.me',
8     'env-thing': 'asdf',
9     'init.author.name': 'Isaac Z. Schlueter',
10     'init.author.email': 'i@izs.me',
11     'init.author.url': 'http://blog.izs.me/',
12     'proprietary-attribs': false,
13     'npm:publishtest': true,
14     '_npmjs.org:couch': 'https://admin:password@localhost:5984/registry',
15     _auth: 'dXNlcm5hbWU6cGFzc3dvcmQ=',
16     'npm-www:nocache': '1',
17     nodedir: '/Users/isaacs/dev/js/node-v0.8',
18     'sign-git-tag': true,
19     message: 'v%s',
20     'strict-ssl': false,
21     'tmp': process.env.HOME + '/.tmp',
22     username : "username",
23     _password : "password",
24     _token:
25      { AuthSession: 'yabba-dabba-doodle',
26        version: '1',
27        expires: '1345001053415',
28        path: '/',
29        httponly: true } }
30
31 var envData = { userconfig: common.userconfig, 'other-env-thing': '1000' }
32
33 var gcData = { 'package-config:foo': 'boo' }
34
35 var biData = { 'builtin-config': true }
36
37 var cli = { foo: 'bar', heading: 'foo', 'git-tag-version': false }
38
39 var expectList =
40 [ cli,
41   envData,
42   ucData,
43   gcData,
44   biData ]
45
46 var expectSources =
47 { cli: { data: cli },
48   env:
49    { data: envData,
50      source: envData,
51      prefix: '' },
52   user:
53    { path: common.userconfig,
54      type: 'ini',
55      data: ucData },
56   global:
57    { path: common.globalconfig,
58      type: 'ini',
59      data: gcData },
60   builtin: { data: biData } }
61
62 test('with builtin', function (t) {
63   npmconf.load(cli, common.builtin, function (er, conf) {
64     if (er) throw er
65     t.same(conf.list, expectList)
66     t.same(conf.sources, expectSources)
67     t.same(npmconf.rootConf.list, [])
68     t.equal(npmconf.rootConf.root, npmconf.defs.defaults)
69     t.equal(conf.root, npmconf.defs.defaults)
70     t.equal(conf.get('heading'), 'foo')
71     t.equal(conf.get('git-tag-version'), false)
72     t.end()
73   })
74 })