diff options
author | Forrest L Norvell <forrest@npmjs.com> | 2015-04-10 13:35:02 +0300 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2015-04-10 13:35:02 +0300 |
commit | c8faf12ee4edce401e107855967fc8da0ea40120 (patch) | |
tree | 2e5ecd6aa0b62c79bf9d1b56bfa8be410d297200 /test | |
parent | 9220e59f8def8c82c6d331a39ba29ad4c44e3a9b (diff) |
test: ensure map-to-registry.js uses common config
Diffstat (limited to 'test')
-rw-r--r-- | test/tap/map-to-registry.js | 124 |
1 files changed, 63 insertions, 61 deletions
diff --git a/test/tap/map-to-registry.js b/test/tap/map-to-registry.js index 72cdbe516..9f6673b92 100644 --- a/test/tap/map-to-registry.js +++ b/test/tap/map-to-registry.js @@ -1,89 +1,91 @@ -var test = require("tap").test -var npm = require("../../") +var test = require('tap').test +var npm = require('../../') -var mapRegistry = require("../../lib/utils/map-to-registry.js") +var common = require('../common-tap.js') +var mapRegistry = require('../../lib/utils/map-to-registry.js') var creds = { - "//registry.npmjs.org/:username" : "u", - "//registry.npmjs.org/:_password" : new Buffer("p").toString("base64"), - "//registry.npmjs.org/:email" : "e" + '//registry.npmjs.org/:username': 'u', + '//registry.npmjs.org/:_password': new Buffer('p').toString('base64'), + '//registry.npmjs.org/:email': 'e', + cache: common.npm_config_cache } -test("setup", function (t) { +test('setup', function (t) { npm.load(creds, function (err) { t.ifError(err) t.end() }) }) -test("mapRegistryToURI", function (t) { +test('mapRegistryToURI', function (t) { t.plan(16) - mapRegistry("basic", npm.config, function (er, uri, auth, registry) { - t.ifError(er, "mapRegistryToURI worked") - t.equal(uri, "https://registry.npmjs.org/basic") + mapRegistry('basic', npm.config, function (er, uri, auth, registry) { + t.ifError(er, 'mapRegistryToURI worked') + t.equal(uri, 'https://registry.npmjs.org/basic') t.deepEqual(auth, { - scope : "//registry.npmjs.org/", - token : undefined, - username : "u", - password : "p", - email : "e", - auth : "dTpw", - alwaysAuth : false + scope: '//registry.npmjs.org/', + token: undefined, + username: 'u', + password: 'p', + email: 'e', + auth: 'dTpw', + alwaysAuth: false }) - t.equal(registry, "https://registry.npmjs.org/") + t.equal(registry, 'https://registry.npmjs.org/') }) - npm.config.set("scope", "test") - npm.config.set("@test:registry", "http://reg.npm/design/-/rewrite/") - npm.config.set("//reg.npm/design/-/rewrite/:_authToken", "a-token") - mapRegistry("simple", npm.config, function (er, uri, auth, registry) { - t.ifError(er, "mapRegistryToURI worked") - t.equal(uri, "http://reg.npm/design/-/rewrite/simple") + npm.config.set('scope', 'test') + npm.config.set('@test:registry', 'http://reg.npm/design/-/rewrite/') + npm.config.set('//reg.npm/design/-/rewrite/:_authToken', 'a-token') + mapRegistry('simple', npm.config, function (er, uri, auth, registry) { + t.ifError(er, 'mapRegistryToURI worked') + t.equal(uri, 'http://reg.npm/design/-/rewrite/simple') t.deepEqual(auth, { - scope : "//reg.npm/design/-/rewrite/", - token : "a-token", - username : undefined, - password : undefined, - email : undefined, - auth : undefined, - alwaysAuth : undefined + scope: '//reg.npm/design/-/rewrite/', + token: 'a-token', + username: undefined, + password: undefined, + email: undefined, + auth: undefined, + alwaysAuth: undefined }) - t.equal(registry, "http://reg.npm/design/-/rewrite/") + t.equal(registry, 'http://reg.npm/design/-/rewrite/') }) - npm.config.set("scope", "") - npm.config.set("@test2:registry", "http://reg.npm/-/rewrite/") - npm.config.set("//reg.npm/-/rewrite/:_authToken", "b-token") - mapRegistry("@test2/easy", npm.config, function (er, uri, auth, registry) { - t.ifError(er, "mapRegistryToURI worked") - t.equal(uri, "http://reg.npm/-/rewrite/@test2%2feasy") + npm.config.set('scope', '') + npm.config.set('@test2:registry', 'http://reg.npm/-/rewrite/') + npm.config.set('//reg.npm/-/rewrite/:_authToken', 'b-token') + mapRegistry('@test2/easy', npm.config, function (er, uri, auth, registry) { + t.ifError(er, 'mapRegistryToURI worked') + t.equal(uri, 'http://reg.npm/-/rewrite/@test2%2feasy') t.deepEqual(auth, { - scope : "//reg.npm/-/rewrite/", - token : "b-token", - username : undefined, - password : undefined, - email : undefined, - auth : undefined, - alwaysAuth : undefined + scope: '//reg.npm/-/rewrite/', + token: 'b-token', + username: undefined, + password: undefined, + email: undefined, + auth: undefined, + alwaysAuth: undefined }) - t.equal(registry, "http://reg.npm/-/rewrite/") + t.equal(registry, 'http://reg.npm/-/rewrite/') }) - npm.config.set("scope", "test") - npm.config.set("@test3:registry", "http://reg.npm/design/-/rewrite/relative") - npm.config.set("//reg.npm/design/-/rewrite/:_authToken", "c-token") - mapRegistry("@test3/basic", npm.config, function (er, uri, auth, registry) { - t.ifError(er, "mapRegistryToURI worked") - t.equal(uri, "http://reg.npm/design/-/rewrite/relative/@test3%2fbasic") + npm.config.set('scope', 'test') + npm.config.set('@test3:registry', 'http://reg.npm/design/-/rewrite/relative') + npm.config.set('//reg.npm/design/-/rewrite/:_authToken', 'c-token') + mapRegistry('@test3/basic', npm.config, function (er, uri, auth, registry) { + t.ifError(er, 'mapRegistryToURI worked') + t.equal(uri, 'http://reg.npm/design/-/rewrite/relative/@test3%2fbasic') t.deepEqual(auth, { - scope : "//reg.npm/design/-/rewrite/", - token : "c-token", - username : undefined, - password : undefined, - email : undefined, - auth : undefined, - alwaysAuth : undefined + scope: '//reg.npm/design/-/rewrite/', + token: 'c-token', + username: undefined, + password: undefined, + email: undefined, + auth: undefined, + alwaysAuth: undefined }) - t.equal(registry, "http://reg.npm/design/-/rewrite/relative/") + t.equal(registry, 'http://reg.npm/design/-/rewrite/relative/') }) }) |