From 922dee31c2dd7b76f1df2f1eaffe799442363b97 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Sat, 30 Jan 2021 12:57:09 -0600 Subject: [PATCH] add tests for licenses reducers --- src/licenses/reducers.test.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/licenses/reducers.test.ts 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); +});