( spy: SpyLike<Self, Args, Return>, expectedCalls: number, )
| 1172 | * @param expectedCalls The number of the expected calls. |
| 1173 | */ |
| 1174 | export function assertSpyCalls< |
| 1175 | Self, |
| 1176 | Args extends unknown[], |
| 1177 | Return, |
| 1178 | >( |
| 1179 | spy: SpyLike<Self, Args, Return>, |
| 1180 | expectedCalls: number, |
| 1181 | ) { |
| 1182 | try { |
| 1183 | assertEquals(spy.calls.length, expectedCalls); |
| 1184 | } catch (e) { |
| 1185 | assertIsError(e); |
| 1186 | let message = spy.calls.length < expectedCalls |
| 1187 | ? "Spy not called as much as expected:\n" |
| 1188 | : "Spy called more than expected:\n"; |
| 1189 | message += e.message.split("\n").slice(1).join("\n"); |
| 1190 | throw new AssertionError(message); |
| 1191 | } |
| 1192 | } |
| 1193 | |
| 1194 | /** Call information recorded by a spy. */ |
| 1195 | export interface ExpectedSpyCall< |
no test coverage detected