Skip to content

Commit

Permalink
Fix bad testing semantics for async errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaptic committed Sep 16, 2024
1 parent 503fd0d commit 89e904b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions test/unit/server/soroban/get_contract_balance_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,19 @@ describe("Server#getContractBalance", function () {
});

it("throws on invalid addresses", function (done) {
expect(
this.server.getSACBalance(Keypair.random().publicKey(), token),
).to.throw(/TypeError/);
this.server
.getSACBalance(Keypair.random().publicKey(), token)
.then(() => done(new Error("Error didn't occur")))
.catch((err) => {
expect(err).to.match(/TypeError/);
});

expect(
this.server.getSACBalance(contract.substring(0, -1), token),
).to.throw(/TypeError/);
this.server
.getSACBalance(contract.substring(0, -1), token)
.then(() => done(new Error("Error didn't occur")))
.catch((err) => {
expect(err).to.match(/TypeError/);
done();
});
});
});

0 comments on commit 89e904b

Please sign in to comment.