-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.js
52 lines (36 loc) · 1.24 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const test = require('ava');
const { createPrivnote, retrievePrivnote, isPrivnoteUrl } = require('./');
test('without passphrase', async t => {
const expectedBody = 'hello world';
const { id, passphrase } = await createPrivnote(expectedBody);
const actualBody = await retrievePrivnote(id, passphrase);
t.is(actualBody, expectedBody);
});
test('with passphrase', async t => {
const expectedBody = 'hello internet';
const passphrase = 'custom passphrase';
const { id } = await createPrivnote(expectedBody, { passphrase });
const actualBody = await retrievePrivnote(id, passphrase);
t.is(actualBody, expectedBody);
});
test('with url', async t => {
const expectedBody = 'hello world';
const { url } = await createPrivnote(expectedBody);
const actualBody = await retrievePrivnote(url);
t.is(actualBody, expectedBody);
});
test('isPrivnoteUrl', async t => {
const valids = [
'https://privnote.com/abcde#fg123',
'https://privnote.com/GqX61SLm#c38LMmEZb',
];
valids.forEach(_ => t.is(isPrivnoteUrl(_), true));
const invalids = [
'test',
'',
'http://privnote.com/abc#123',
'https://privnote.com/abc#123?',
'https://privnote.com/abc#',
];
invalids.forEach(_ => t.is(isPrivnoteUrl(_), false));
});