forked from sindresorhus/new-github-issue-url
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
47 lines (38 loc) · 972 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
47
import test from 'ava';
import newGithubIssueUrl from '.';
test('main', t => {
const user = 'sindresorhus';
const repo = 'test';
const body = 'Hello';
const title = 'Title';
const urlString = newGithubIssueUrl({
user,
repo,
body,
title
});
const {searchParams} = new URL(urlString);
t.true(urlString.includes(user));
t.true(urlString.includes(repo));
t.is(searchParams.get('body'), body);
t.is(searchParams.get('title'), title);
});
test('repoUrl option', t => {
const repoUrl = 'https://github.com/sindresorhus/test';
const body = 'Hello';
const title = 'Title';
const urlString = newGithubIssueUrl({
repoUrl,
body,
title
});
const {searchParams} = new URL(urlString);
t.true(urlString.startsWith(repoUrl));
t.is(searchParams.get('body'), body);
t.is(searchParams.get('title'), title);
});
test('throws when required options are not specified', t => {
t.throws(() => {
newGithubIssueUrl();
}, /need to specify either/);
});