From 37b44592de043a996bdaeb61d2f790ab5d6fff76 Mon Sep 17 00:00:00 2001 From: Harvey Sanders Date: Tue, 6 Feb 2024 12:33:55 -0500 Subject: [PATCH] Wait for test hooks to resolve --- test/test-projects.js | 44 ++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/test/test-projects.js b/test/test-projects.js index eee5c78..ab936c6 100644 --- a/test/test-projects.js +++ b/test/test-projects.js @@ -236,19 +236,25 @@ describe('projects', function () { }); describe('#shelveProject()', function () { - function removeTestProjectFiles() { - [ - `${projectsDirectory}/underpants`, - `${projectsDirectory}/scratch-pad`, - `${projectsDirectory}/_underpants`, - `${projectsDirectory}/__underpants`, - `${projectsDirectory}/_scratch-pad`, - `${projectsDirectory}/__scratch-pad` - ].forEach(path => { - if (fs.existsSync(path)) { - rimraf(path, () => {}); - } - }); + async function removeTestProjectFiles() { + return Promise.all( + [ + `${projectsDirectory}/underpants`, + `${projectsDirectory}/scratch-pad`, + `${projectsDirectory}/_underpants`, + `${projectsDirectory}/__underpants`, + `${projectsDirectory}/_scratch-pad`, + `${projectsDirectory}/__scratch-pad` + ].map( + path => + new Promise((resolve, reject) => { + if (fs.existsSync(path)) { + rimraf(path, resolve); + } + resolve(true); + }) + ) + ); } beforeEach(removeTestProjectFiles); @@ -269,14 +275,10 @@ describe('projects', function () { ).to.be.false; bddStdin('y\n'); projects.shelveProject(dummySession.PROJECT[0]).then(function (resPath) { - expect( - fs.existsSync(path), - `path: "${path}" should not exist` - ).to.be.false; - expect( - fs.existsSync(newPath), - `path: "${newPath}" should exist` - ).to.be.true; + expect(fs.existsSync(path), `path: "${path}" should not exist`).to.be + .false; + expect(fs.existsSync(newPath), `path: "${newPath}" should exist`).to.be + .true; expect(resPath).to.equal(newPath); done(); });