mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-13 18:14:09 +00:00
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
// SPDX-License-Identifier: MIT
|
|
// Copyright (c) 2021-2022 The Pybricks Authors
|
|
|
|
import { AnyAction } from 'redux';
|
|
import {
|
|
FailToFinishReasonType,
|
|
didFailToFinish,
|
|
didFinish,
|
|
didProgress,
|
|
didStart,
|
|
} from './actions';
|
|
import reducers from './reducers';
|
|
|
|
type State = ReturnType<typeof reducers>;
|
|
|
|
test('initial state', () => {
|
|
expect(reducers(undefined, {} as AnyAction)).toMatchInlineSnapshot(`
|
|
Object {
|
|
"flashing": false,
|
|
"installPybricksDialog": Object {
|
|
"isOpen": false,
|
|
},
|
|
"progress": null,
|
|
"restoreOfficialDialog": Object {
|
|
"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);
|
|
});
|
|
|
|
test('progress', () => {
|
|
expect(reducers({ progress: 1 } as State, didStart()).progress).toBe(null);
|
|
expect(reducers({ progress: null } as State, didProgress(1)).progress).toBe(1);
|
|
});
|