// 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; 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); });