-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathtest.js
33 lines (26 loc) · 1.16 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import test from 'ava';
import semver from 'semver';
import semverRegex from 'semver-regex';
import latestVersion, {PackageNotFoundError, VersionNotFoundError} from './index.js';
test('latest version', async t => {
t.regex(await latestVersion('ava'), semverRegex());
});
test('latest version with version', async t => {
t.true(semver.satisfies(await latestVersion('package-json', {version: '0'}), '0.x'));
});
test('latest version with dist-tag', async t => {
t.true(semver.satisfies(await latestVersion('npm', {version: 'latest-5'}), '5.x'));
});
test('latest version scoped', async t => {
t.regex(await latestVersion('@sindresorhus/df'), semverRegex());
});
test('registry url', async t => {
t.regex(await latestVersion('npm', {registryUrl: 'https://registry.yarnpkg.com/'}), semverRegex());
});
test('include deprecated', async t => {
t.regex(await latestVersion('querystring', {version: '0.2', omitDeprecated: false}), semverRegex());
});
test('throws if not found', async t => {
await t.throwsAsync(latestVersion('nnnope'), {instanceOf: PackageNotFoundError});
await t.throwsAsync(latestVersion('npm', {version: '0.0.0'}), {instanceOf: VersionNotFoundError});
});