Test Failed
Push — master ( 1271ab...04a38e )
by Dmytro
03:35 queued 11s
created

tests/mock/Telegraph.js   A

Complexity

Total Complexity 4
Complexity/F 4

Size

Lines of Code 25
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 14
mnd 3
bc 3
fnc 1
dl 0
loc 25
rs 10
bpm 3
cpm 4
noi 0
c 0
b 0
f 0
1
/* eslint-disable security/detect-object-injection */
2
import { axiosResponse } from './utils';
3
4
export default function (opts) {
5
    if (opts.method === 'POST' && opts.url.match('createPage')) {
6
        return axiosResponse({
7
            url   : 'http://telegra.ph/my_page_url',
8
            title : opts.data.title
9
        });
10
    }
11
12
    if (opts.method === 'GET' && opts.url.match('createAccount')) {
13
        return axiosResponse({
14
            'short_name'   : opts.params.short_name,
15
            'access_token' : 'abc_abc'
16
        });
17
    }
18
19
    if (opts.method === 'GET' && opts.url.match('getAccountInfo')) {
20
        return axiosResponse({
21
            'short_name' : 'My_created_account'
22
        });
23
    }
24
25
    throw new Error(`unknown telegra.ph method: ${JSON.stringify(opts)}`);
26
}
27