Test Failed
Push — master ( 1c3ca4...d8d5e6 )
by Dmytro
02:05 queued 10s
created

tests/Test.js   A

Complexity

Total Complexity 4
Complexity/F 1

Size

Lines of Code 31
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 18
mnd 0
bc 0
fnc 4
dl 0
loc 31
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10
1
import path from 'path';
2
import fse from 'fs-extra';
3
import aes from 'lib/aes';
4
import seeds from 'seeds';
5
import { tmpFolder, entry } from './constants';
6
import { mockAPI, unMockAPI, trackedLogs } from './mock';
7
import './init-hooks';
8
9
mockAPI();
10
11
class Test {
12
    async cleanup() {
13
        trackedLogs.length = 0;
14
    }
15
16
    parseToken(token) {
17
        return aes.decrypt(token);
18
    }
19
20
    getToken() {
21
        return aes.encrypt({
22
            c : -389952175,
23
            u : 238585617,
24
            d : +new Date()
25
        });
26
    }
27
28
    async getTracks() {
29
        return trackedLogs;
30
    }
31
32
    async setTmpFolder() {
33
        await fse.ensureDir(tmpFolder);
34
    }
35
36
    async cleanTmpFolder() {
37
        await fse.remove(tmpFolder);
38
    }
39
40
    mockAPI = mockAPI
41
42
    unMockAPI= unMockAPI
43
}
44
45
46
function load(relPath) {
47
    // eslint-disable-next-line security/detect-non-literal-require
48
    return require(path.join(entry, relPath));
49
}
50
51
function resolve(relPath) {
52
    return require.resolve(path.join(entry, relPath));
53
}
54
55
export default new Test();
56
57
export {
58
    tmpFolder,
59
    entry,
60
    load,
61
    resolve,
62
    seeds
63
};
64