-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.js
46 lines (37 loc) · 927 Bytes
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
import test from 'ava';
import newGithubReleaseUrl from './index.js';
test('main', t => {
const user = 'sindresorhus';
const repo = 'test';
const tag = 'v9.9.9';
const body = 'Hello';
const urlString = newGithubReleaseUrl({
user,
repo,
tag,
body,
});
const {searchParams} = new URL(urlString);
t.true(urlString.includes(user));
t.true(urlString.includes(repo));
t.is(searchParams.get('tag'), tag);
t.is(searchParams.get('body'), body);
});
test('repoUrl option', t => {
const repoUrl = 'https://github.com/sindresorhus/test';
const body = 'Hello';
const urlString = newGithubReleaseUrl({
repoUrl,
body,
});
const {searchParams} = new URL(urlString);
t.true(urlString.startsWith(repoUrl));
t.is(searchParams.get('body'), body);
});
test('throws when required options are not specified', t => {
t.throws(() => {
newGithubReleaseUrl();
}, {
message: /need to specify either/,
});
});