add test for editor saga

This commit is contained in:
David Lechner
2020-06-10 21:59:34 -05:00
committed by David Lechner
parent 31c3e2b52e
commit 5c3ec89e3b
4 changed files with 44 additions and 2 deletions
+21
View File
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: MIT
// Copyright (c) 2020 The Pybricks Authors
import { Ace } from 'ace-builds';
import { mock } from 'jest-mock-extended';
import { AsyncSaga } from '../../test';
import { reloadProgram } from '../actions/editor';
import editor from './editor';
test('reloadProgram', async () => {
const saga = new AsyncSaga(editor);
const mockEditor = mock<Ace.EditSession>();
saga.setState({ editor: { current: mockEditor } });
saga.put(reloadProgram());
expect(mockEditor.setValue).toHaveBeenCalled();
await saga.end();
});