Total Complexity | 3 |
Complexity/F | 1 |
Lines of Code | 43 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import path from 'path'; |
||
2 | import { assert } from 'chai'; |
||
3 | import { load } from '../utils'; |
||
4 | import seedJSON from '../files/seed.json'; |
||
5 | import { testsRootFolder } from '../constants'; |
||
6 | |||
7 | const { getFiles, safeReadJSON } = load('utils/fileUtils'); |
||
8 | |||
9 | suite('fileUtils'); |
||
10 | |||
11 | test('Positive: getFiles', async function () { |
||
12 | const dir = path.join(testsRootFolder, 'files'); |
||
13 | const files = await getFiles(dir); |
||
14 | |||
15 | assert.include( |
||
16 | files, |
||
17 | path.join(testsRootFolder, 'files/seed.json') |
||
18 | ); |
||
19 | |||
20 | assert.include( |
||
21 | files, |
||
22 | path.join(testsRootFolder, 'files/subdir/inner.js') |
||
23 | ); |
||
24 | }); |
||
25 | |||
26 | test('Positive: safeReadJSON', async function () { |
||
27 | const file = path.join(testsRootFolder, 'files/seed.json'); |
||
28 | |||
29 | assert.deepEqual( |
||
30 | await safeReadJSON(file), |
||
31 | seedJSON |
||
32 | ); |
||
33 | }); |
||
34 | |||
35 | test('Negative: safeReadJSON', async function () { |
||
36 | const file = path.join(testsRootFolder, 'files/not_exists.json'); |
||
37 | const def = { 'not_exists': true }; |
||
38 | |||
39 | assert.deepEqual( |
||
40 | await safeReadJSON(file, def), |
||
41 | def |
||
42 | ); |
||
43 | }); |
||
44 |