Skip to content

Commit

Permalink
Wait for test hooks to resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
harveysanders committed Feb 6, 2024
1 parent 8b7c355 commit 37b4459
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions test/test-projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
});
Expand Down

0 comments on commit 37b4459

Please sign in to comment.