diff --git a/src/licenses/reducers.test.ts b/src/licenses/reducers.test.ts new file mode 100644 index 00000000..1fbdfdae --- /dev/null +++ b/src/licenses/reducers.test.ts @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2021 The Pybricks Authors + +import { Action } from '../actions'; +import { didFetchList, select } from './actions'; +import reducers, { LicenseInfo, LicenseList } from './reducers'; + +type State = ReturnType; + +test('initial state', () => { + expect(reducers(undefined, {} as Action)).toMatchInlineSnapshot(` + Object { + "list": null, + "selected": null, + } + `); +}); + +test('list', () => { + const list = [] as LicenseList; + expect(reducers({ list: null } as State, didFetchList(list)).list).toBe(list); +}); + +test('selected', () => { + const info = {} as LicenseInfo; + expect(reducers({ selected: null } as State, select(info)).selected).toBe(info); +});