Skip to content

Commit

Permalink
Remove useless not null assertions on errors (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghusse committed Apr 2, 2022
1 parent 122faf6 commit 0af8dc5
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions test/tests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,18 +749,20 @@ describe("node-saml /", function () {
it("must have a cert to construct a SAML object", function () {
try {
new SAML(noCertSamlConfig);
} catch (err: any) {
} catch (err: unknown) {
expect(err).to.exist;
expect(err!.message!).to.match(/cert is required/);
expect(err).to.be.instanceOf(Error);
expect((err as Error).message).to.match(/cert is required/);
}
});

it("must have a valid cert to construct a SAML object", function () {
try {
new SAML(badCertSamlConfig);
} catch (err: any) {
} catch (err: unknown) {
expect(err).to.exist;
expect(err!.message!).to.match(/cert is required/);
expect(err).to.be.instanceOf(Error);
expect((err as Error).message).to.match(/cert is required/);
}
});

Expand All @@ -782,9 +784,10 @@ describe("node-saml /", function () {
it("SAML creation should fail without cert", function () {
try {
new SAML(noCertSamlConfig);
} catch (err: any) {
} catch (err: unknown) {
expect(err).to.exist;
expect(err!.message!).to.match(/cert is required/);
expect(err).to.be.instanceOf(Error);
expect((err as Error).message).to.match(/cert is required/);
}
});

Expand Down Expand Up @@ -952,9 +955,9 @@ describe("node-saml /", function () {
try {
await samlObj.validatePostResponseAsync(container);
expect(true).to.not.exist;
} catch (err: any) {
} catch (err) {
expect(err).to.exist;
expect(err!).to.equal(errorToReturn);
expect(err).to.equal(errorToReturn);
}
});

Expand Down Expand Up @@ -1558,8 +1561,9 @@ describe("node-saml /", function () {
try {
const { profile } = await samlObj.validatePostResponseAsync(container);
expect(profile).to.not.exist;
} catch (err: any) {
expect(err!.message).to.eq("InResponseTo is missing from response");
} catch (err: unknown) {
expect(err).to.be.instanceOf(Error);
expect((err as Error).message).to.eq("InResponseTo is missing from response");
}
});

Expand Down

0 comments on commit 0af8dc5

Please sign in to comment.