|
| 1 | +import test from 'ava'; |
| 2 | +import {_createFixture} from '../_helpers/stub-execa.js'; |
| 3 | + |
| 4 | +/** @type {ReturnType<typeof _createFixture<import('../../source/util.js')>>} */ |
| 5 | +const createFixture = _createFixture('../../source/util.js', import.meta.url); |
| 6 | + |
| 7 | +test('main', createFixture, [{ |
| 8 | + command: 'npm access get status @my/pkg --json', |
| 9 | + stdout: '{"@my/pkg": "public"}', |
| 10 | +}], async ({t, testedModule: {getNpmPackageAccess}}) => { |
| 11 | + t.is( |
| 12 | + await getNpmPackageAccess({name: '@my/pkg'}), |
| 13 | + 'public', |
| 14 | + ); |
| 15 | +}); |
| 16 | + |
| 17 | +test('with publishConfig.registry', createFixture, [{ |
| 18 | + command: 'npm access get status @my/pkg --json --registry https://registry.npmjs.org/', |
| 19 | + stdout: '{"@my/pkg": "public"}', |
| 20 | +}], async ({t, testedModule: {getNpmPackageAccess}}) => { |
| 21 | + t.is( |
| 22 | + await getNpmPackageAccess({ |
| 23 | + name: '@my/pkg', |
| 24 | + publishConfig: { |
| 25 | + registry: 'https://registry.npmjs.org/', |
| 26 | + }, |
| 27 | + }), |
| 28 | + 'public', |
| 29 | + ); |
| 30 | +}); |
| 31 | + |
| 32 | +test('with external registry', createFixture, [{ |
| 33 | + command: 'npm access get status @my/pkg --json --registry http://my-internal-registry.local', |
| 34 | + stdout: '{"@my/pkg": "private"}', |
| 35 | +}], async ({t, testedModule: {getNpmPackageAccess}}) => { |
| 36 | + t.is( |
| 37 | + await getNpmPackageAccess({ |
| 38 | + name: '@my/pkg', |
| 39 | + publishConfig: { |
| 40 | + registry: 'http://my-internal-registry.local', |
| 41 | + }, |
| 42 | + }), |
| 43 | + 'private', |
| 44 | + ); |
| 45 | +}); |
0 commit comments