src/__tests__/checker.js   A
last analyzed

Complexity

Total Complexity 5
Complexity/F 1

Size

Lines of Code 29
Function Count 5

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 19
mnd 0
bc 0
fnc 5
dl 0
loc 29
rs 10
bpm 0
cpm 1
noi 1
c 0
b 0
f 0
1
import fetch from 'node-fetch';
2
3
import { isFetchError } from '../checker';
4
5
describe('isFetchError', () => {
6
	it('checks isomorphic-fetch Response Error correctly', () => {
7
		const e = new Response('', { status: 404 });
0 ignored issues
show
Bug introduced by
The variable Response seems to be never declared. If this is a global, consider adding a /** global: Response */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
8
		const result = isFetchError(e);
9
		expect(result).toBe(true);
10
	});
11
12
	it('checks node-fetch Response Error correctly', () => {
13
		const e = new fetch.Response('', { status: 404 });
14
		const result = isFetchError(e);
15
		expect(result).toBe(true);
16
	});
17
18
	it('checks fetch Network Error correctly', () => {
19
		const e = new fetch.FetchError('some message');
20
		const result = isFetchError(e);
21
		expect(result).toBe(true);
22
	});
23
24
	it('check system error correctly', () => {
25
		const e = new Error('some message');
26
		const result = isFetchError(e);
27
		expect(result).toBe(false);
28
	});
29
});
30