diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/utils/config/definitions.js | 15 | ||||
-rw-r--r-- | test/lib/utils/config/flatten.js | 6 |
2 files changed, 21 insertions, 0 deletions
diff --git a/test/lib/utils/config/definitions.js b/test/lib/utils/config/definitions.js index 3169feefb..830468c43 100644 --- a/test/lib/utils/config/definitions.js +++ b/test/lib/utils/config/definitions.js @@ -695,3 +695,18 @@ t.test('user-agent', t => { t.equal(flat.userAgent, expectCI) t.end() }) + +t.test('save-prefix', t => { + const obj = { + 'save-exact': true, + 'save-prefix': '~1.2.3', + } + const flat = {} + definitions['save-prefix'] + .flatten('save-prefix', { ...obj, 'save-exact': true }, flat) + t.strictSame(flat, { savePrefix: '' }) + definitions['save-prefix'] + .flatten('save-prefix', { ...obj, 'save-exact': false }, flat) + t.strictSame(flat, { savePrefix: '~1.2.3' }) + t.end() +}) diff --git a/test/lib/utils/config/flatten.js b/test/lib/utils/config/flatten.js index 9fac0820c..6fc91b484 100644 --- a/test/lib/utils/config/flatten.js +++ b/test/lib/utils/config/flatten.js @@ -6,6 +6,8 @@ delete process.env.NODE process.execPath = '/path/to/node' const obj = { + 'save-exact': true, + 'save-prefix': 'ignored', 'save-dev': true, '@foobar:registry': 'https://foo.bar.com/', '//foo.bar.com:_authToken': 'foobarbazquuxasdf', @@ -15,6 +17,8 @@ const obj = { const flat = flatten(obj) t.strictSame(flat, { saveType: 'dev', + saveExact: true, + savePrefix: '', '@foobar:registry': 'https://foo.bar.com/', '//foo.bar.com:_authToken': 'foobarbazquuxasdf', npmBin: '/path/to/npm', @@ -26,6 +30,8 @@ t.strictSame(flat, { process.env.NODE = '/usr/local/bin/node.exe' flatten({ 'save-dev': false }, flat) t.strictSame(flat, { + saveExact: true, + savePrefix: '', '@foobar:registry': 'https://foo.bar.com/', '//foo.bar.com:_authToken': 'foobarbazquuxasdf', npmBin: '/path/to/npm', |