Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4749 from trufflesuite/fix/box-rejects
Browse files Browse the repository at this point in the history
Await `assert.rejects` in box tests
  • Loading branch information
cds-amal authored Feb 17, 2022
2 parents 3bc71e2 + f73f9ce commit c394163
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/box/test/sandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ describe("Box.sandbox", () => {
assert(config.truffle_directory);
});

it("errors when passed an invalid options configuration", () => {
it("errors when passed an invalid options configuration", async () => {
options = { name: "badBox", force: true, setGracefulCleanup: true };
assert.rejects(async () => {
await assert.rejects(async () => {
await sandbox(options);
}, "should have rejected!");
});
Expand Down
24 changes: 13 additions & 11 deletions packages/box/test/utils-unbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ describe("utils", () => {
});

describe("fetchRepository", () => {
it("rejects when passed non-strings and non-objects", () => {
assert.rejects(async () => {
it("rejects when passed non-strings and non-objects", async () => {
await assert.rejects(async () => {
await utils.fetchRepository(false);
}, "should have rejected!");

assert.rejects(async () => {
await assert.rejects(async () => {
await utils.fetchRepository(123214);
}, "should have rejected!");
});
});

describe("verifySourcePath", async() => {
describe("verifySourcePath", async () => {
const errorStatus = 401;
const errorMessage = "Network error: oh noes!";
const authError = {
Expand All @@ -43,10 +43,11 @@ describe("utils", () => {
},
message: errorMessage
};
let url;

before(async() => {
before(async () => {
url = "https://github.com/truffle-box/bare-box";
sinon.stub(axios, 'head').throws(authError);
sinon.stub(axios, "head").throws(authError);
});

it("Includes network error message on non 404 failure", async () => {
Expand All @@ -55,11 +56,12 @@ describe("utils", () => {
assert(false, "verifyVCSURL should have thrown!");
} catch (error) {
const { response, message } = error;
assert.equal(response.status, errorStatus);
assert(message.endsWith(errorMessage), "Axios error message should be the suffix");
assert.equal(response.status, errorStatus);
assert(
message.endsWith(errorMessage),
"Axios error message should be the suffix"
);
}
})

});
});

});

0 comments on commit c394163

Please sign in to comment.