Test Failed
Push — master ( da8f38...0105cb )
by Dmytro
01:49
created

tests/utils/resolve-url.test.js   A

Complexity

Total Complexity 6
Complexity/F 1

Size

Lines of Code 51
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 28
mnd 0
bc 0
fnc 6
dl 0
loc 51
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10
1
/* eslint-disable sonarjs/no-duplicate-string */
2
import { assert } from 'chai';
3
import { load } from '../Test';
4
5
const { resolveUrl } = load('utils');
6
7
suite('resolveUrl');
8
9
test('use relativeUrl as absolute', async function () {
10
    assert.equal(
11
        resolveUrl('http://uvvewwik.pl/cob', 'http://tarku.gp/oje'),
12
        'http://tarku.gp/oje'
13
    );
14
});
15
16
test('respect apiprefix', async function () {
17
    assert.equal(
18
        resolveUrl('http://uvvewwik.pl/cob', 'oje'),
19
        'http://uvvewwik.pl/cob/oje'
20
    );
21
});
22
23
24
test('handle first / in relativeUrl', async function () {
25
    assert.equal(
26
        resolveUrl('http://uvvewwik.pl/cob', '/oje'),
27
        'http://uvvewwik.pl/cob/oje'
28
    );
29
});
30
31
32
test('handle last / in baseUrl', async function () {
33
    assert.equal(
34
        resolveUrl('http://uvvewwik.pl/', '/oje'),
35
        'http://uvvewwik.pl/oje'
36
    );
37
});
38
39
40
test('empty baseUrl', async function () {
41
    assert.equal(
42
        resolveUrl(null, 'http://nunpe.mn/tiv'),
43
        'http://nunpe.mn/tiv'
44
    );
45
});
46
47
test('handle last / in apiprefix', async function () {
48
    assert.equal(
49
        resolveUrl('http://saero.mt/gum/', '/oje'),
50
        'http://saero.mt/gum/oje'
51
    );
52
});
53