From 1e368fba0871f3e7f4dff1b4cf760aa1a210576d Mon Sep 17 00:00:00 2001 From: David Sanders Date: Mon, 13 May 2024 13:49:10 -0700 Subject: [PATCH] test: fix awaiting process.nextTick --- tests/renderer/components/editors-spec.tsx | 6 +++--- .../components/settings-general-appearance-spec.tsx | 2 +- tests/renderer/runner-spec.tsx | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/renderer/components/editors-spec.tsx b/tests/renderer/components/editors-spec.tsx index b23ce8e6ef..81f3b8809c 100644 --- a/tests/renderer/components/editors-spec.tsx +++ b/tests/renderer/components/editors-spec.tsx @@ -172,7 +172,7 @@ describe('Editors component', () => { emitEvent('select-all-in-editor'); - await process.nextTick; + await new Promise(process.nextTick); expect(editor.setSelection).toHaveBeenCalledWith('range'); }); @@ -185,7 +185,7 @@ describe('Editors component', () => { emitEvent('select-all-in-editor'); - await process.nextTick; + await new Promise(process.nextTick); expect(editor.getModel).toHaveBeenCalledTimes(1); expect(editor.setSelection).not.toHaveBeenCalled(); }); @@ -237,7 +237,7 @@ describe('Editors component', () => { editorMosaic.focusedEditor = jest.fn().mockReturnValue(editor); emitEvent('select-all-in-editor'); - await process.nextTick; + await new Promise(process.nextTick); expect(editor.setSelection).toHaveBeenCalledWith(range); }); diff --git a/tests/renderer/components/settings-general-appearance-spec.tsx b/tests/renderer/components/settings-general-appearance-spec.tsx index 4a790b5b98..ad92a1b712 100644 --- a/tests/renderer/components/settings-general-appearance-spec.tsx +++ b/tests/renderer/components/settings-general-appearance-spec.tsx @@ -53,7 +53,7 @@ describe('AppearanceSettings component', () => { />, ); - await process.nextTick; + await new Promise(process.nextTick); expect((wrapper.state() as any).selectedTheme?.name).toBe('defaultDark'); }); diff --git a/tests/renderer/runner-spec.tsx b/tests/renderer/runner-spec.tsx index e597c932e1..06d2703afb 100644 --- a/tests/renderer/runner-spec.tsx +++ b/tests/renderer/runner-spec.tsx @@ -215,7 +215,7 @@ describe('Runner component', () => { const result = await instance.run(); expect(result).toBe(RunResult.SUCCESS); - await process.nextTick; + await new Promise(process.nextTick); expect(window.ElectronFiddle.cleanupDirectory).toHaveBeenCalledTimes(1); expect(window.ElectronFiddle.deleteUserData).toHaveBeenCalledTimes(1); expect(window.ElectronFiddle.deleteUserData).toHaveBeenCalledWith( @@ -230,7 +230,7 @@ describe('Runner component', () => { const result = await instance.run(); expect(result).toBe(RunResult.SUCCESS); - await process.nextTick; + await new Promise(process.nextTick); expect(window.ElectronFiddle.cleanupDirectory).toHaveBeenCalledTimes(1); });