Test Failed
Push — master ( 96bf47...0b3edf )
by Dmytro
03:06 queued 12s
created

tests/package/actions.test.js   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 53
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 38
mnd 0
bc 0
fnc 1
dl 0
loc 53
rs 10
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
1
import { assert } from 'chai';
2
import chronicle  from '../entry';
3
4
suite('Actions');
5
6
test('Manually setting required attributes', function () {
7
    const action = chronicle.action({ title: 'get users', group: 'Users' });
8
9
    action.url = 'http://localhost:8080/api/users?status=ACTIVE';
10
11
    action.response = {
12
        headers : { 'content-type': 'application/json' },
13
        code    : 200,
14
        body    : []
15
    };
16
17
    const {
18
        request,
19
        response,
20
        context
21
    } = action.data;
22
23
    assert.equal(context.title, 'get users');
24
    assert.equal(context.group, 'Users');
25
26
    assert.deepEqual(request, {
27
        href     : 'http://localhost:8080/api/users?status=ACTIVE',
28
        origin   : 'http://localhost:8080',
29
        protocol : 'http:',
30
        hostname : 'localhost',
31
        port     : '8080',
32
        path     : '/api/users',
33
        query    : { status: 'ACTIVE' },
34
        method   : 'GET',
35
        headers  : null
36
    });
37
38
    assert.deepOwnInclude(response, {
39
        headers : { 'content-type': 'application/json' },
40
        'http'  : {
41
            'version' : '1.1'
42
        },
43
        'info' : {
44
            'charset' : 'utf-8',
45
            'type'    : 'application/json'
46
        },
47
        'status' : {
48
            'code'    : 200,
49
            'message' : 'OK'
50
        },
51
        body : []
52
    });
53
});
54
55
56
// import { Chronicle, axios, request } from 'rest-chronicle';
57
58
// const chronicle = new Chronicle({
59
//     version : 'v1',
60
//     prefix  : 'api/v1'
61
// });
62
// // const axios = new Axios({
63
// //     with     : 'mocha',
64
// //     instance : chronicle
65
// // });
66
67
// axios({
68
//     with         : this,
69
//     method       : 'get',
70
//     url          : 'http://bit.ly/2mTM3nY',
71
//     responseType : 'stream'
72
// });
73
74
// {
75
//     const action = chronicle.action('get users', 'Users');
76
77
//     action.url = 'http://localhost:8080/api/v1/users?status=ACTIVE';
78
//     action.response = {
79
//         headers : { 'content-type': 'application/json' },
80
//         code    : 200,
81
//         body    : []
82
//     };
83
//     // action.method = 'GET';
84
// }
85
86
// // methods
87
// // with
88
// // desc
89
// // comment
90
// // tag
91
92
// axios
93
//     .with(this)
94
//     .desc('additional descr')
95
//     .comment('some text')
96
//     .get('/user/12345');
97
98
// request
99
//     .with(this)
100
//     .get('/products')
101
//     .expect(200);
102
103
// // const instane1 = axios.create({
104
// //     baseURL : 'https://some-domain.com/api/',
105
// //     timeout : 1000,
106
// //     headers : { 'X-Custom-Header': 'foobar' }
107
// // });
108
109
110
// chronicle.save('filePath', {});
111
// chronicle.saveMany('groups_to_files', {});
112
// chronicle.clear();
113
114