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

tests/mock/Telegram.js   A

Complexity

Total Complexity 5
Complexity/F 5

Size

Lines of Code 21
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 11
mnd 4
bc 4
fnc 1
dl 0
loc 21
rs 10
bpm 4
cpm 5
noi 0
c 0
b 0
f 0
1
/* eslint-disable security/detect-object-injection */
2
import { axiosResponse, axiosError } from './utils';
3
4
export default function (opts) {
5
    if (opts.method === 'POST' && opts.url.match('sendMessage')) {
6
        return axiosResponse();
7
    }
8
9
    if (opts.url.match('getChat')) {
10
        if (opts.data.chat_id === 400) {
11
            throw axiosError('Request failed with status code 400', { 'ok': false, 'error_code': 400, 'description': 'Bad Request: chat not found' });
12
        }
13
14
        return axiosResponse({ username: 'thick' });
15
    }
16
17
    if (opts.url.match('sendDocument')) {
18
        return axiosResponse();
19
    }
20
21
    throw new Error('unknown telegram method');
22
}
23