add tests for editor reducers

This commit is contained in:
David Lechner
2021-02-01 10:26:05 -06:00
parent bf2bb5e81d
commit 6ed5dca8ce
+27
View File
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 The Pybricks Authors
import { Ace } from 'ace-builds';
import { Action } from '../actions';
import { setEditSession } from './actions';
import reducers from './reducers';
type State = ReturnType<typeof reducers>;
test('initial state', () => {
expect(reducers(undefined, {} as Action)).toMatchInlineSnapshot(`
Object {
"current": null,
}
`);
});
test('current', () => {
const session = {} as Ace.EditSession;
expect(reducers({ current: null } as State, setEditSession(session)).current).toBe(
session,
);
expect(
reducers({ current: session } as State, setEditSession(undefined)).current,
).toBe(null);
});