Adam Cameron
<cfscript>
// MyCoolLibrary.cfm
function testMe() {
if (avoidRunningMe()) {
return "one fish"
}
return "two fish"
}
function avoidRunningMe() {
// really slow or is destructive or has external dependencies or something
}
</cfscript>
The library is just included when one wants to use it, eg like this:
describe("Testing MyCoolLibrary", () => {
include "MyCoolLibrary.cfm"
it("checks testMe does the right thing", () => {
// now I need to mock avoidRunningMe before calling testMe...?
})
})
Adam Cameron
domwatson
02/23/2022, 11:49 AMAdam Cameron
Adam Cameron
import test.BaseSpec
component extends=BaseSpec {
function run() {
describe("Testing MyCoolLibrary", () => {
include "MyCoolLibrary.cfm"
it("checks testMe does the right thing", () => {
prepareMock(this) // <---------------
this.$("avoidRunningMe").$results("whatevs")
result = testMe()
// etc
})
})
}
}
domwatson
02/23/2022, 2:50 PMdomwatson
02/23/2022, 2:50 PMAdam Cameron
Adam Cameron
Adam Cameron
describe
block... either in the run
or before it... yes it does work.Adam Cameron
import test.BaseSpec
component extends=BaseSpec {
include "MyCoolLibrary.cfm"
function run() {
describe("Testing MyCoolLibrary", () => {
it("checks testMe does the right thing", () => {
prepareMock(this)
this.$("avoidRunningMe").$results("whatevs")
result = testMe()
// etc
})
})
}
}