* Asserts that `Deno.test` is called with the correct options for the `describe` call in the callback function. * This is used to reduce code duplication when testing calling `describe` with different call signatures.
(
expectedOptions: Omit<Deno.TestDefinition, "name" | "fn">,
cb: (fns: readonly [Spy, Spy]) => void,
)
| 1092 | * This is used to reduce code duplication when testing calling `describe` with different call signatures. |
| 1093 | */ |
| 1094 | async function assertIgnoreOptions( |
| 1095 | expectedOptions: Omit<Deno.TestDefinition, "name" | "fn">, |
| 1096 | cb: (fns: readonly [Spy, Spy]) => void, |
| 1097 | ) { |
| 1098 | using test = stub(Deno, "test"); |
| 1099 | const fns = [spy(), spy()] as const; |
| 1100 | try { |
| 1101 | cb(fns); |
| 1102 | assertSpyCall(test, 0); |
| 1103 | const call = test.calls[0]; |
| 1104 | const options = call?.args[0] as Deno.TestDefinition; |
| 1105 | assertEquals( |
| 1106 | Object.keys(options).sort(), |
| 1107 | ["name", "fn", ...Object.keys(expectedOptions)].sort(), |
| 1108 | ); |
| 1109 | assertObjectMatch(options, { |
| 1110 | name: "example", |
| 1111 | ...expectedOptions, |
| 1112 | }); |
| 1113 | |
| 1114 | assertSpyCalls(fns[0], 0); |
| 1115 | assertSpyCalls(fns[1], 0); |
| 1116 | |
| 1117 | const context = new TestContext("example"); |
| 1118 | const result = options.fn(context); |
| 1119 | assertStrictEquals(Promise.resolve(result), result); |
| 1120 | assertEquals(await result, undefined); |
| 1121 | assertSpyCalls(context.spies.step, 0); |
| 1122 | |
| 1123 | assertSpyCalls(fns[0], 0); |
| 1124 | assertSpyCalls(fns[1], 0); |
| 1125 | } finally { |
| 1126 | TestSuiteInternal.reset(); |
| 1127 | } |
| 1128 | } |
| 1129 | /** |
| 1130 | * Asserts that `Deno.test` is called with just the name, ignore, and function for the `describe.ignore` call in the callback function. |
| 1131 | * In addition to that, it asserts that the individual test cases registered with `it` use the test step API correctly. |
no test coverage detected