mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
c46143f0ac
* chore: update copyright year * fix --------- Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
23 lines
519 B
TypeScript
23 lines
519 B
TypeScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
// deno-lint-ignore-file no-explicit-any
|
|
|
|
export const MOCK_SYMBOL = Symbol.for("@MOCK");
|
|
|
|
export type MockCall = {
|
|
args: any[];
|
|
returned?: any;
|
|
thrown?: any;
|
|
timestamp: number;
|
|
returns: boolean;
|
|
throws: boolean;
|
|
};
|
|
|
|
export function getMockCalls(f: any): MockCall[] {
|
|
const mockInfo = f[MOCK_SYMBOL];
|
|
if (!mockInfo) {
|
|
throw new Error("Received function must be a mock or spy function");
|
|
}
|
|
|
|
return [...mockInfo.calls];
|
|
}
|