From 35881729de8563ea52b35cc92e6887bc5ef58455 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Sat, 30 Dec 2017 21:03:40 +0200 Subject: [PATCH] test: version not found --- test/index.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/index.ts b/test/index.ts index 6a7bee8c65..191f64938c 100644 --- a/test/index.ts +++ b/test/index.ts @@ -303,3 +303,33 @@ test('error is thrown when package is not found in registry', async t => { t.end() } }) + +test('error is thrown when there is no package found for the requested version', async t => { + try { + await resolveFromNpm({ alias: 'is-positive', pref: '1000.0.0' }, { registry }) + t.fail('installation should have failed') + } catch (err) { + t.ok(err.message.startsWith('No compatible version found: is-positive@1000.0.0'), 'failed with correct error message') + t.end() + } +}) + +test('error is thrown when there is no package found for the requested range', async t => { + try { + await resolveFromNpm({ alias: 'is-positive', pref: '^1000.0.0' }, { registry }) + t.fail('installation should have failed') + } catch (err) { + t.ok(err.message.startsWith('No compatible version found: is-positive@>=1000.0.0 <1001.0.0'), 'failed with correct error message') + t.end() + } +}) + +test('error is thrown when there is no package found for the requested tag', async t => { + try { + await resolveFromNpm({ alias: 'is-positive', pref: 'unknown-tag' }, { registry }) + t.fail('installation should have failed') + } catch (err) { + t.ok(err.message.startsWith('No compatible version found: is-positive@unknown-tag'), 'failed with correct error message') + t.end() + } +})