Passed
Push — main ( 3f259d...71e4ad )
by Patrick
02:34
created

tests/lib/HistoryManager.test.ts   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 21
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 1
mnd 1
bc 1
fnc 0
bpm 0
cpm 0
noi 0
1
import { HistoryManager } from '@/lib/HistoryManager';
2
import { existsSync, unlinkSync } from 'fs';
3
4
it('loads run history from file', () => {
5
    const historyManager = new HistoryManager(`${__dirname}/../fixtures/history.json`);
6
7
    expect(historyManager.data).toHaveLength(2);
8
});
9
10
it('saves to a new file if it does not exist', () => {
11
    const filename = `${__dirname}/../fixtures/temp/history.json`;
12
    if (existsSync(filename)) {
13
        unlinkSync(filename);
14
    }
15
16
    const historyManager = new HistoryManager(filename);
17
18
    expect(historyManager.data).toHaveLength(0);
19
    expect(existsSync(filename)).toBeTruthy();
20
});
21