From 7c4caf4b02bfb2c3f7bcfd3f0ef1a060c0e7c630 Mon Sep 17 00:00:00 2001 From: Danielku15 Date: Sun, 19 Jan 2025 20:49:15 +0100 Subject: [PATCH] test: reactivate second test --- .../integration/config-file-change.test.ts | 88 +++++++++---------- src/test/util.ts | 4 +- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/test/integration/config-file-change.test.ts b/src/test/integration/config-file-change.test.ts index 09da81b..fcfde0b 100644 --- a/src/test/integration/config-file-change.test.ts +++ b/src/test/integration/config-file-change.test.ts @@ -23,50 +23,50 @@ import { describe('config-file-change', () => { const workspaceFolder = integrationTestPrepare('config-file-change'); - // it('rename-flow', async () => { - // let c: Controller | undefined = await getController(); - - // // initial state - // await c.scanFiles(); - // expectTestTree(c, [ - // ['folder', [['nested.test.js', [['is nested']]]]], - // ['hello.test.js', [['math', [['addition'], ['subtraction']]]]], - // ]); - - // // rename mocha file - // await fs.rename( - // path.join(workspaceFolder, '.mocharc.js'), - // path.join(workspaceFolder, '.__mocharc.js'), - // ); - // await onceDisposed(c); - - // // controller should be gone - // expect(await tryGetController(false)).to.be.undefined; - - // // rename back - // await fs.rename( - // path.join(workspaceFolder, '.__mocharc.js'), - // path.join(workspaceFolder, '.mocharc.js'), - // ); - - // // wait for controller - // for (let retry = 0; retry < 5; retry++) { - // c = await tryGetController(false); - // if (!c) { - // await setTimeout(1000); - // } else { - // break; - // } - // } - - // // scan and test results - // expect(c).to.not.be.undefined; - // await c!.scanFiles(); - // expectTestTree(c!, [ - // ['folder', [['nested.test.js', [['is nested']]]]], - // ['hello.test.js', [['math', [['addition'], ['subtraction']]]]], - // ]); - // }); + it('rename-flow', async () => { + let c: Controller | undefined = await getController(); + + // initial state + await c.scanFiles(); + expectTestTree(c, [ + ['folder', [['nested.test.js', [['is nested']]]]], + ['hello.test.js', [['math', [['addition'], ['subtraction']]]]], + ]); + + // rename mocha file + await fs.rename( + path.join(workspaceFolder, '.mocharc.js'), + path.join(workspaceFolder, '.__mocharc.js'), + ); + await onceDisposed(c); + + // controller should be gone + expect(await tryGetController(false)).to.be.undefined; + + // rename back + await fs.rename( + path.join(workspaceFolder, '.__mocharc.js'), + path.join(workspaceFolder, '.mocharc.js'), + ); + + // wait for controller + for (let retry = 0; retry < 5; retry++) { + c = await tryGetController(false); + if (!c) { + await setTimeout(1000); + } else { + break; + } + } + + // scan and test results + expect(c).to.not.be.undefined; + await c!.scanFiles(); + expectTestTree(c!, [ + ['folder', [['nested.test.js', [['is nested']]]]], + ['hello.test.js', [['math', [['addition'], ['subtraction']]]]], + ]); + }); it('delete-create-flow', async () => { let c: Controller | undefined = await getController(); diff --git a/src/test/util.ts b/src/test/util.ts index 3a0c410..8e309ae 100644 --- a/src/test/util.ts +++ b/src/test/util.ts @@ -65,8 +65,8 @@ export function integrationTestPrepare(name: string) { afterEach(async () => { await restoreWorkspace(workspaceFolder, workspaceBackup); try { - const c = getController(false); - (await c).scanFiles(); + const c = await getController(false); + await c.scanFiles(); } catch (e) { // ignore }