Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove useless not null assertions on errors #50

Merged
merged 3 commits into from
Apr 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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