-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathreducers.test.ts
More file actions
44 lines (40 loc) · 1.21 KB
/
reducers.test.ts
File metadata and controls
44 lines (40 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// SPDX-License-Identifier: MIT
// Copyright (c) 2021-2026 The Pybricks Authors
import { AnyAction } from 'redux';
import {
FailToFinishReasonType,
didFailToFinish,
didFinish,
didStart,
} from './actions';
import reducers from './reducers';
type State = ReturnType<typeof reducers>;
test('initial state', () => {
expect(reducers(undefined, {} as AnyAction)).toMatchInlineSnapshot(`
{
"dfuWindowsDriverInstallDialog": {
"isOpen": false,
},
"flashing": false,
"installPybricksDialog": {
"isOpen": false,
},
"isFirmwareFlashEV3InProgress": false,
"isFirmwareFlashUsbDfuInProgress": false,
"isFirmwareRestoreOfficialDfuInProgress": false,
"restoreOfficialDialog": {
"isOpen": false,
},
}
`);
});
test('flashing', () => {
expect(reducers({ flashing: false } as State, didStart()).flashing).toBe(true);
expect(reducers({ flashing: true } as State, didFinish()).flashing).toBe(false);
expect(
reducers(
{ flashing: true } as State,
didFailToFinish(FailToFinishReasonType.TimedOut),
).flashing,
).toBe(false);
});