Last active
April 18, 2022 14:13
Star
You must be signed in to star a gist
Tests for probable bug with notToThrow assertion.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import test.BaseSpec | |
component extends=BaseSpec { | |
function run() { | |
describe("Tests TestBox assertions", () => { | |
describe("Tests toThrow", () => { | |
it("should pass because it DOES throw an exception with the matching message", () => { | |
expect(() => throwExceptionWithMatchingMessage()).toThrow(regex="^.*MATCH_THIS.*$") | |
}) | |
}) | |
describe("Tests notToThrow", () => { | |
it("should pass because it is throwing a different exception", () => { | |
expect(() => throwDifferentException()).notToThrow(regex="^.*MATCH_THIS.*$") | |
}) | |
it("should fail because it DOES throw an exception with the matching message", () => { | |
expect(() => throwExceptionWithMatchingMessage()).notToThrow(regex="^.*MATCH_THIS.*$") | |
}) | |
it("should fail because it DOES throw an exception with the matching detail", () => { | |
expect(() => throwExceptionWithMatchingDetail()).notToThrow(regex="^.*MATCH_THIS.*$") | |
}) | |
it("should fail because it DOES throw an exception that matches on both message and detail", () => { | |
expect(() => throwExceptionWithMatchingMessageAndDetail()).notToThrow(regex="^.*MATCH_THIS.*$") | |
}) | |
}) | |
}) | |
} | |
function throwExceptionWithMatchingMessage() { | |
throw(message="MESSAGE_MATCH_THIS") | |
} | |
function throwExceptionWithMatchingDetail() { | |
throw(detail="DETAIL_MATCH_THIS") | |
} | |
function throwExceptionWithMatchingMessageAndDetail() { | |
throw(message="BOTH_MATCH_THIS", detail="BOTH_MATCH_THIS") | |
} | |
function throwDifferentException() { | |
throw(message="DIFFERENT_MESSAGE", detail="DETAIL_MATCH_THIS") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment