-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
30 lines (28 loc) · 957 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
import test from 'ava';
import makeTable from './lib/jira-table';
import {parsePath} from './';
test('makeTable', t => {
const result = makeTable(['Header 1', 'Header 2'], [['foo', 'bar']]);
t.truthy(result);
t.regex(result, /\|\|Header 1\|\|Header 2\|\|/);
t.regex(result, /\|foo\|bar\|/);
});
test('parsePath', t => {
t.deepEqual(parsePath('123/456'), {projectID: '123', issueTypeID: '456'});
t.deepEqual(parsePath('/123/456/'), {projectID: '123', issueTypeID: '456'});
t.throws(() => {
parsePath('/');
}, /Project ID and Issue Type ID are required in the path/);
t.throws(() => {
parsePath('');
}, /Project ID and Issue Type ID are required in the path/);
t.throws(() => {
parsePath('/123/');
}, /Issue Type ID is required in the path/);
t.throws(() => {
parsePath('/123');
}, /Issue Type ID is required in the path/);
t.throws(() => {
parsePath('/123/456/789');
}, /Too many segments in path/);
});