Passed
Push — master ( d2bce4...71830f )
by Dmytro
130:29 queued 126:43
created

tests/cli/jira.ls.test.js   A

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 46
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 30
mnd 0
bc 0
fnc 4
dl 0
loc 46
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10
1
import { assert } from 'chai';
2
import Test from '../Test';
3
import { CLITester, getApiCalls, load } from '../utils';
4
5
const jiraRunner = load('bin/jira').default;
6
7
const factory = new Test();
8
9
suite('cli jira list');
10
11
before(async function () {
12
    await factory.setTmpFolder();
13
    await factory.saveProfile('jira_default', factory.jira_default);
14
});
15
16
test('jira ls -dm', async function () {
17
    const tester = new CLITester([], factory);
18
19
    const [ output ] = await Promise.all([
20
        tester.test(),
21
        jiraRunner([ 'ls', '-dm' ])
22
    ]);
23
24
    const apiCalls = await getApiCalls('type=requestSent');
25
26
    assert.lengthOf(apiCalls, 2);
27
    apiCalls.forEach(req => {
28
        assert.equal(req.method, 'GET');
29
        assert.equal(req.url, '/rest/api/3/search');
30
        assert.equal(
31
            req.params.jql,
32
            'assignee was currentuser() AND status IN ("1", "2") AND Sprint in openSprints()'
33
        );
34
    });
35
    const [ first, second ] = apiCalls;
36
37
    assert.notExists(first.params.startAt);
38
    assert.exists(second.params.startAt, 'second request for paggination');
39
40
    assert.match(output, new RegExp('A-1.*brief tie pool present sharp'));
41
    assert.match(output, new RegExp('A-2.*symbol stock taste combine identity'));
42
    assert.match(output, new RegExp('A-3.*continent safe area fun especially end various love stick down balloon sense come our whispered old line environment trade'));
43
});
44
45
after(async function () {
46
    await factory.cleanTmpFolder();
47
});
48