add tests for licenses reducers

This commit is contained in:
David Lechner
2021-02-01 10:26:05 -06:00
parent b7061f63b4
commit 922dee31c2
+27
View File
@@ -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<typeof reducers>;
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);
});