TTF tests for misc functions that don't fit another category
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
<cfscript> | |
void function run() { | |
describe("Tests of it", () => { | |
it("prefixes its message with ""It""", () => { | |
savecontent variable="message" { | |
it("IS A TEST MESSAGE", () => {}) | |
} | |
tinyTest.results.pass-- | |
expect(message).toInclude("It IS A TEST MESSAGE") | |
}) | |
}) | |
describe("Tests of expect", () => { | |
it("exists", () => { | |
expect("NOT_TESTED") | |
}) | |
it("returns a struct with keys for matcher callbacks", () => { | |
var result = expect("NOT_TESTED") | |
if (isNull(result) || isNull(result.toBe) || !isCustomFunction(local.result.toBe)) { | |
throw(type="TinyTest.TestFailedException") | |
} | |
}) | |
}) | |
describe("Tests of fail", () => { | |
it("fails a test", (type) => { | |
try { | |
fail() | |
} catch (TinyTest.FailureException e) { | |
// OK | |
} catch (any e) { | |
throw(type="TinyTest.TestFailedException") | |
} | |
}) | |
}) | |
describe("Test of test result visualisations", () => { | |
it("specifies that a pass should have positive emphasis", () => { | |
savecontent variable="message" { | |
it("is a passing test", () => { | |
expect(true).toBeTrue() | |
}) | |
} | |
expect(message).toInclude('is a passing test: <span class="pass">OK</span>') | |
}) | |
it("specifies that a fail should have negative emphasis", () => { | |
savecontent variable="message" { | |
it("is a failing test", () => { | |
expect(false).toBeTrue() | |
}) | |
} | |
expect(message).toInclude('is a failing test: <span class="fail"><em>Failed</em></span>') | |
}) | |
it("specifies that an error should have more emphasis than a fail", () => { | |
savecontent variable="message" { | |
it("is an erroring test", () => { | |
throw(type="", message="TEST_EXCEPTION", detail="TEST_EXCEPTION_DETAIL") | |
}) | |
} | |
expect(message).toInclude('is an erroring test: <span class="error"><strong>Error: [TEST_EXCEPTION][TEST_EXCEPTION_DETAIL]</strong></span>') | |
}) | |
tinyTest.results.pass-- | |
tinyTest.results.fail-- | |
tinyTest.results.error-- | |
}) | |
} | |
tinyTest.runTests() | |
</cfscript> |
Where do you run the code on?
It's called from this one: https://gist.github.com/adamcameron/838b30252bb0a390bdf324a8ab10b753, which I run via trycf.com
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where do you run the code on?