]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/npm-api-not-loaded-error.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / npm-api-not-loaded-error.js
1 var test = require("tap").test
2 var npm = require("../..")
3 var path = require("path")
4 var rimraf = require("rimraf")
5 var npmrc = path.join(__dirname, "npmrc")
6 var fs = require("fs")
7
8 test("setup", function (t) {
9   fs.writeFileSync(npmrc, "foo = bar\n", "ascii")
10   t.end()
11 })
12
13 test("calling set/get on config pre-load should throw", function (t) {
14   var threw = true
15   try {
16     npm.config.get("foo")
17     threw = false
18   } catch (er) {
19     t.equal(er.message, "npm.load() required")
20   } finally {
21     t.ok(threw, "get before load should throw")
22   }
23
24   threw = true
25   try {
26     npm.config.set("foo", "bar")
27     threw = false
28   } catch (er) {
29     t.equal(er.message, "npm.load() required")
30   } finally {
31     t.ok(threw, "set before load should throw")
32   }
33
34   npm.load({ userconfig: npmrc }, function (er) {
35     if (er)
36       throw er
37     t.equal(npm.config.get("foo"), "bar")
38     npm.config.set("foo", "baz")
39     t.equal(npm.config.get("foo"), "baz")
40     t.end()
41   })
42 })
43
44 test("cleanup", function (t) {
45   rimraf.sync(npmrc)
46   t.end()
47 })