-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtest.js
More file actions
40 lines (29 loc) · 968 Bytes
/
test.js
File metadata and controls
40 lines (29 loc) · 968 Bytes
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
import test from 'ava';
import execa from 'execa';
// Note: Before running `npm test` make sure to reset the API key and delete the db.json file (or just run `bitly --purge`)
test('Test --help output', async t => {
const ret = await execa.shell('node ./cli.js --help');
t.regex(ret.stdout, /Usage/);
});
test('--version', async t => {
const {stdout} = await execa.shell('node ./cli.js --version');
t.true(typeof stdout.length === 'number');
});
test('--list', async t => {
const error = await t.throwsAsync(() => {
return execa.shell('node ./cli.js --list');
});
t.regex(error.message, /found/);
});
test('Invalid URL', async t => {
const error = await t.throwsAsync(() => {
return execa.shell('node ./cli.js --url foo');
});
t.regex(error.message, /URL/);
});
test('Invalid token', async t => {
const error = await t.throwsAsync(() => {
return execa.shell('node ./cli.js --url google.com');
});
t.regex(error.message, /node-bitly/);
});