2 var path = require("path")
4 var test = require('tap').test
5 var mkdirp = require('mkdirp')
6 var rimraf = require('rimraf')
7 var mr = require('npm-registry-mock')
8 var common = require('../common-tap')
11 var pkg = path.join(__dirname, "publish-access")
13 test('setup', function (t) {
14 mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
15 t.ifError(err, 'registry mocked successfully')
22 test('scoped packages pass public access if set', function (t) {
23 server.filteringRequestBody(function (body) {
24 t.doesNotThrow(function () {
25 var parsed = JSON.parse(body)
26 t.equal(parsed.access, 'public', 'access level is correct')
27 }, 'converted body back into object')
29 }).put('/@bigco%2fpublish-access', true).reply(201, {ok: true})
31 mkdirp(path.join(pkg, 'cache'), function () {
33 path.join(pkg, "package.json"),
35 name: '@bigco/publish-access',
41 t.ifError(er, 'package file written')
46 '--cache', path.join(pkg, 'cache'),
47 '--loglevel', 'silly',
48 '--registry', common.registry
54 t.ifError(er, 'published without error')
65 test("cleanup", function (t) {
66 process.chdir(__dirname)
68 rimraf(pkg, function (er) {