diff --git a/src/editor/reducers.test.ts b/src/editor/reducers.test.ts new file mode 100644 index 00000000..b53531bc --- /dev/null +++ b/src/editor/reducers.test.ts @@ -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; + +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); +});