Passed
Push — master ( 649d64...cc116d )
by Dmytro
02:15 queued 11s
created

tests/utils.js   A

Complexity

Total Complexity 3
Complexity/F 1.5

Size

Lines of Code 19
Function Count 2

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 13
mnd 1
bc 1
fnc 2
dl 0
loc 19
bpm 0.5
cpm 1.5
noi 1
c 0
b 0
f 0
rs 10
1
import { assert } from 'chai';
2
import md5 from 'md5';
3
import fs from 'fs-extra';
4
5
export async function checkError(promise, type, message) {
6
    try {
7
        await promise;
8
        assert.fail();
9
    } catch (error) {
10
        assert.equal(error.name, type, error.toString());
11
        assert.match(error.message, new RegExp(message), error.toString());
12
    }
13
}
14
15
export async function checkMD5(file, hash) {
16
    const buff = await fs.readFile(file);
17
18
    assert.equal(md5(buff), hash, `${Buffer.byteLength(buff)}: ${buff.toString()}`);
19
}
20