Skip to content

Commit 31fb3b9

Browse files
committed
test: drop state from AsyncSaga constructor params
This uses the real rootReducer to populate the initial state in the test AsyncSaga. This way we don't have to populate default values. Since it isn't used often, we can omit the parameter and just call the updateState() method after creating the object if modifications are needed.
1 parent 7b08d8a commit 31fb3b9

File tree

9 files changed

+114
-267
lines changed

9 files changed

+114
-267
lines changed

src/editor/sagas.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jest.mock('file-saver');
1313

1414
test('open', async () => {
1515
const mockEditor = mock<monaco.editor.ICodeEditor>();
16-
const saga = new AsyncSaga(editor, {}, { editor: mockEditor });
16+
const saga = new AsyncSaga(editor, { editor: mockEditor });
1717

1818
const data = new Uint8Array().buffer;
1919
saga.put(open(data));
@@ -26,7 +26,7 @@ test('open', async () => {
2626
describe('saveAs', () => {
2727
test('web file system api can succeed', async () => {
2828
const mockEditor = mock<monaco.editor.ICodeEditor>();
29-
const saga = new AsyncSaga(editor, {}, { editor: mockEditor });
29+
const saga = new AsyncSaga(editor, { editor: mockEditor });
3030

3131
// window.showSaveFilePicker is not defined in the test environment
3232
// so we can't use spyOn().
@@ -55,7 +55,7 @@ describe('saveAs', () => {
5555

5656
test('web file system api can fail', async () => {
5757
const mockEditor = mock<monaco.editor.ICodeEditor>();
58-
const saga = new AsyncSaga(editor, {}, { editor: mockEditor });
58+
const saga = new AsyncSaga(editor, { editor: mockEditor });
5959

6060
// window.showSaveFilePicker is not defined in the test environment
6161
// so we can't use spyOn().
@@ -82,7 +82,7 @@ describe('saveAs', () => {
8282

8383
test('fallback can succeed', async () => {
8484
const mockEditor = mock<monaco.editor.ICodeEditor>();
85-
const saga = new AsyncSaga(editor, {}, { editor: mockEditor });
85+
const saga = new AsyncSaga(editor, { editor: mockEditor });
8686

8787
const mockFileSaverSaveAs = jest.spyOn(FileSaver, 'saveAs');
8888

@@ -101,7 +101,7 @@ describe('saveAs', () => {
101101

102102
test('fallback can fail', async () => {
103103
const mockEditor = mock<monaco.editor.ICodeEditor>();
104-
const saga = new AsyncSaga(editor, {}, { editor: mockEditor });
104+
const saga = new AsyncSaga(editor, { editor: mockEditor });
105105

106106
const testError = new Error('test error');
107107
const mockFileSaverSaveAs = jest

src/explorer/sagas.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('handleExplorerImportFiles', () => {
2121
const testFileName = 'test.py';
2222
const testFileContents = '# test';
2323

24-
const saga = new AsyncSaga(explorer, { fileStorage: { fileNames: [] } });
24+
const saga = new AsyncSaga(explorer);
2525

2626
jest.spyOn(browserFsAccess, 'fileOpen').mockResolvedValueOnce([
2727
mock<FileWithHandle>({

0 commit comments

Comments
 (0)