( expectedOptions: Omit<Deno.TestDefinition, "name" | "fn">, cb: (fn: Spy) => void, )
| 115 | } |
| 116 | |
| 117 | async function assertItOptions( |
| 118 | expectedOptions: Omit<Deno.TestDefinition, "name" | "fn">, |
| 119 | cb: (fn: Spy) => void, |
| 120 | ) { |
| 121 | using test = stub(Deno, "test"); |
| 122 | const fn = spy(); |
| 123 | try { |
| 124 | cb(fn); |
| 125 | |
| 126 | assertSpyCalls(fn, 0); |
| 127 | assertSpyCall(test, 0); |
| 128 | const call = test.calls[0]; |
| 129 | const options = call?.args[0] as Deno.TestDefinition; |
| 130 | assertEquals( |
| 131 | Object.keys(options).sort(), |
| 132 | ["name", "fn", ...Object.keys(expectedOptions)].sort(), |
| 133 | ); |
| 134 | assertObjectMatch(options, { |
| 135 | name: "example", |
| 136 | ...expectedOptions, |
| 137 | }); |
| 138 | |
| 139 | const context = new TestContext("example"); |
| 140 | const result = options.fn(context); |
| 141 | assertStrictEquals(Promise.resolve(result), result); |
| 142 | assertEquals(await result, undefined); |
| 143 | assertSpyCalls(context.spies.step, 0); |
| 144 | assertSpyCall(fn, 0, { |
| 145 | self: {}, |
| 146 | args: [context], |
| 147 | returned: undefined, |
| 148 | }); |
| 149 | assertSpyCalls(fn, 1); |
| 150 | } finally { |
| 151 | TestSuiteInternal.reset(); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | export async function assertMinimumItOptions( |
| 156 | cb: (fn: Spy) => void, |
no test coverage detected