mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 01:23:52 +00:00
add tests for editor reducers
This commit is contained in:
@@ -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);
|
||||
});
|
||||
Reference in New Issue
Block a user