Skip to main content
Module

x/mock/asserts_test.ts

Utilities to help mock behavior, spy on function calls, stub methods, and fake time for tests.
Very Popular
Go to Latest
File
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162
import { AssertionError, assertRejects, assertThrows } from "./deps.ts";import { assertPassthrough, assertSpyCall, assertSpyCallArg, assertSpyCallArgs, assertSpyCallAsync, assertSpyCalls, assertSpyCallsMin, PassthroughOptions,} from "./asserts.ts";import { Point } from "./test_shared.ts";import { Spy, spy } from "./spy.ts";import { Stub, stub } from "./stub.ts";
Deno.test("assertPassthrough function", () => { const point: Point = new Point(2, 3); const point2: Point = new Point(3, 4); const callToString: (point: Point) => string = (point: Point) => { return point.toString(); };
assertPassthrough({ func: callToString, args: [point], returned: "6, 7", target: { instance: point, method: "toString", self: point, args: [], returned: "6, 7", }, }); assertThrows( () => assertPassthrough({ func: callToString, args: [point], returned: "2, 3", target: { instance: point, method: "toString", args: [point], returned: "6, 7", }, }), AssertionError, "passthrough did not return expected value", ); assertThrows( () => assertPassthrough({ func: callToString, args: [point], returned: "6, 7", target: { instance: point, method: "toString", self: point2, args: [], returned: "6, 7", }, }), AssertionError, "target not called on expected self", ); assertThrows( () => assertPassthrough({ func: callToString, args: [point], returned: "6, 7", target: { instance: point, method: "toString", args: [5, 6], returned: "6, 7", }, }), AssertionError, "target not called with expected args", ); assertThrows( () => assertPassthrough({ func: callToString, args: [5, 8], returned: "6, 7", target: { instance: point, method: "toString", args: [point], returned: "6, 7", }, }), AssertionError, "passthrough did not return expected value", );});
Deno.test("assertPassthrough instance", () => { const point: Point = new Point(2, 3); const point2: Point = new Point(3, 4); const callAction: (a: number, b: number) => number = ( a: number, b: number, ) => { return 3 * point.action.call(point2, a * 2, b * 2); }; const fakePoint: Partial<Point> = { action: callAction };
assertPassthrough({ instance: fakePoint, method: "action", args: [5, 8], returned: 9, target: { instance: point, self: point2, args: [10, 16], returned: 3, }, }); assertThrows( () => assertPassthrough({ instance: fakePoint, method: "action", args: [5, 8], returned: 15, target: { instance: point, self: point2, args: [10, 16], returned: 3, }, }), AssertionError, "passthrough did not return expected value", ); assertThrows( () => assertPassthrough({ instance: fakePoint, method: "action", args: [5, 8], returned: 9, target: { instance: point, self: point, args: [10, 16], returned: 3, }, }), AssertionError, "target not called on expected self", ); assertThrows( () => assertPassthrough({ instance: fakePoint, method: "action", args: [5, 8], returned: 9, target: { instance: point, self: point2, args: [19, 16], returned: 3, }, }), AssertionError, "target not called with expected args", ); assertThrows( () => assertPassthrough({ instance: fakePoint, method: "action", target: { instance: point, self: point2, }, }), AssertionError, "passthrough did not return expected value", ); assertThrows( () => assertPassthrough({ instance: fakePoint, args: [5, 8], returned: 9, target: { instance: point, self: point2, args: [10, 16], returned: 3, }, } as unknown as PassthroughOptions<Partial<Point>, Point>), Error, "target instance or passthrough must have method", ); assertThrows( () => assertPassthrough({ instance: fakePoint, method: "invalid", args: [5, 8], returned: 9, target: { instance: point, self: point2, args: [10, 16], returned: 3, }, }), Error, "passthrough not a function", );});
Deno.test("assertSpyCalls", () => { const spyFunc: Spy<void> = spy();
assertSpyCalls(spyFunc, 0); assertThrows( () => assertSpyCalls(spyFunc, 1), AssertionError, "spy not called as much as expected", );
spyFunc(); assertSpyCalls(spyFunc, 1); assertThrows( () => assertSpyCalls(spyFunc, 0), AssertionError, "spy called more than expected", ); assertThrows( () => assertSpyCalls(spyFunc, 2), AssertionError, "spy not called as much as expected", );});
Deno.test("assertSpyCallsMin", () => { const spyFunc: Spy<void> = spy();
assertSpyCallsMin(spyFunc, 0); assertThrows( () => assertSpyCallsMin(spyFunc, 1), AssertionError, "spy not called as much as expected", );
spyFunc(); assertSpyCallsMin(spyFunc, 1); assertThrows( () => assertSpyCallsMin(spyFunc, 2), AssertionError, "spy not called as much as expected", );});
Deno.test("assertSpyCall function", () => { const spyFunc: Spy<void> = spy(() => 5);
assertThrows( () => assertSpyCall(spyFunc, 0), AssertionError, "spy not called as much as expected", );
spyFunc(); assertSpyCall(spyFunc, 0); assertSpyCall(spyFunc, 0, { args: [], self: undefined, returned: 5, }); assertSpyCall(spyFunc, 0, { args: [], }); assertSpyCall(spyFunc, 0, { self: undefined, }); assertSpyCall(spyFunc, 0, { returned: 5, });
assertThrows( () => assertSpyCall(spyFunc, 0, { args: [1], self: {}, returned: 2, }), AssertionError, "spy not called with expected args", ); assertThrows( () => assertSpyCall(spyFunc, 0, { args: [1], }), AssertionError, "spy not called with expected args", ); assertThrows( () => assertSpyCall(spyFunc, 0, { self: {}, }), AssertionError, "spy not called as method on expected self", ); assertThrows( () => assertSpyCall(spyFunc, 0, { returned: 2, }), AssertionError, "spy call did not return expected value", ); assertThrows( () => assertSpyCall(spyFunc, 0, { error: { msg: "x" }, }), AssertionError, "spy call did not throw an error, a value was returned.", ); assertThrows( () => assertSpyCall(spyFunc, 1), AssertionError, "spy not called as much as expected", );});
Deno.test("assertSpyCall method", () => { const point: Point = new Point(2, 3); const spyMethod: Spy<Point> = spy(point, "action");
assertThrows( () => assertSpyCall(spyMethod, 0), AssertionError, "spy not called as much as expected", );
point.action(3, 7); assertSpyCall(spyMethod, 0); assertSpyCall(spyMethod, 0, { args: [3, 7], self: point, returned: 3, }); assertSpyCall(spyMethod, 0, { args: [3, 7], }); assertSpyCall(spyMethod, 0, { self: point, }); assertSpyCall(spyMethod, 0, { returned: 3, });
assertThrows( () => assertSpyCall(spyMethod, 0, { args: [7, 4], self: undefined, returned: 7, }), AssertionError, "spy not called with expected args", ); assertThrows( () => assertSpyCall(spyMethod, 0, { args: [7, 3], }), AssertionError, "spy not called with expected args", ); assertThrows( () => assertSpyCall(spyMethod, 0, { self: undefined, }), AssertionError, "spy not expected to be called as method on object", ); assertThrows( () => assertSpyCall(spyMethod, 0, { returned: 7, }), AssertionError, "spy call did not return expected value", ); assertThrows( () => assertSpyCall(spyMethod, 1), AssertionError, "spy not called as much as expected", );
spyMethod(9); assertSpyCall(spyMethod, 1); assertSpyCall(spyMethod, 1, { args: [9], self: undefined, returned: 9, }); assertSpyCall(spyMethod, 1, { args: [9], }); assertSpyCall(spyMethod, 1, { self: undefined, }); assertSpyCall(spyMethod, 1, { returned: 9, });
assertThrows( () => assertSpyCall(spyMethod, 1, { args: [7, 4], self: point, returned: 7, }), AssertionError, "spy not called with expected args", ); assertThrows( () => assertSpyCall(spyMethod, 1, { args: [7, 3], }), AssertionError, "spy not called with expected args", ); assertThrows( () => assertSpyCall(spyMethod, 1, { self: point, }), AssertionError, "spy not called as method on expected self", ); assertThrows( () => assertSpyCall(spyMethod, 1, { returned: 7, }), AssertionError, "spy call did not return expected value", ); assertThrows( () => assertSpyCall(spyMethod, 1, { error: { msg: "x" }, }), AssertionError, "spy call did not throw an error, a value was returned.", ); assertThrows( () => assertSpyCall(spyMethod, 2), AssertionError, "spy not called as much as expected", );});
class ExampleError extends Error {}class OtherError extends Error {}
Deno.test("assertSpyCall error", () => { const spyFunc: Spy<void> = spy(() => { throw new ExampleError("failed"); });
assertThrows(() => spyFunc(), ExampleError, "fail"); assertSpyCall(spyFunc, 0); assertSpyCall(spyFunc, 0, { args: [], self: undefined, error: { Class: ExampleError, msg: "fail", }, }); assertSpyCall(spyFunc, 0, { args: [], }); assertSpyCall(spyFunc, 0, { self: undefined, }); assertSpyCall(spyFunc, 0, { error: { Class: ExampleError, msg: "fail", }, }); assertSpyCall(spyFunc, 0, { error: { Class: Error, msg: "fail", }, });
assertThrows( () => assertSpyCall(spyFunc, 0, { args: [1], self: {}, error: { Class: OtherError, msg: "fail", }, }), AssertionError, "spy not called with expected args", ); assertThrows( () => assertSpyCall(spyFunc, 0, { args: [1], }), AssertionError, "spy not called with expected args", ); assertThrows( () => assertSpyCall(spyFunc, 0, { self: {}, }), AssertionError, "spy not called as method on expected self", ); assertThrows( () => assertSpyCall(spyFunc, 0, { error: { Class: OtherError, msg: "fail", }, }), AssertionError, 'Expected error to be instance of "OtherError", but was "ExampleError".', ); assertThrows( () => assertSpyCall(spyFunc, 0, { error: { Class: OtherError, msg: "x", }, }), AssertionError, 'Expected error to be instance of "OtherError", but was "ExampleError".', ); assertThrows( () => assertSpyCall(spyFunc, 0, { error: { Class: ExampleError, msg: "x", }, }), AssertionError, 'Expected error message to include "x", but got "failed".', ); assertThrows( () => assertSpyCall(spyFunc, 0, { error: { Class: Error, msg: "x", }, }), AssertionError, 'Expected error message to include "x", but got "failed".', ); assertThrows( () => assertSpyCall(spyFunc, 0, { error: { msg: "x", }, }), AssertionError, 'Expected error message to include "x", but got "failed".', ); assertThrows( () => assertSpyCall(spyFunc, 0, { returned: 7, }), AssertionError, "spy call did not return expected value, an error was thrown.", ); assertThrows( () => assertSpyCall(spyFunc, 1), AssertionError, "spy not called as much as expected", );});
Deno.test("assertSpyCallAsync function", async () => { const spyFunc: Spy<void> = spy(() => Promise.resolve(5));
await assertRejects( () => assertSpyCallAsync(spyFunc, 0), AssertionError, "spy not called as much as expected", );
await spyFunc(); await assertSpyCallAsync(spyFunc, 0); await assertSpyCallAsync(spyFunc, 0, { args: [], self: undefined, returned: 5, }); await assertSpyCallAsync(spyFunc, 0, { args: [], self: undefined, returned: Promise.resolve(5), }); await assertSpyCallAsync(spyFunc, 0, { args: [], }); await assertSpyCallAsync(spyFunc, 0, { self: undefined, }); await assertSpyCallAsync(spyFunc, 0, { returned: Promise.resolve(5), });
await assertRejects( () => assertSpyCallAsync(spyFunc, 0, { args: [1], self: {}, returned: 2, }), AssertionError, "spy not called with expected args", ); await assertRejects( () => assertSpyCallAsync(spyFunc, 0, { args: [1], }), AssertionError, "spy not called with expected args", ); await assertRejects( () => assertSpyCallAsync(spyFunc, 0, { self: {}, }), AssertionError, "spy not called as method on expected self", ); await assertRejects( () => assertSpyCallAsync(spyFunc, 0, { returned: 2, }), AssertionError, "spy call did not resolve to expected value", ); await assertRejects( () => assertSpyCallAsync(spyFunc, 0, { returned: Promise.resolve(2), }), AssertionError, "spy call did not resolve to expected value", ); await assertRejects( () => assertSpyCallAsync(spyFunc, 1), AssertionError, "spy not called as much as expected", );});
Deno.test("assertSpyCallAsync method", async () => { const point: Point = new Point(2, 3); const spyMethod: Stub<Point> = stub( point, "action", (x?: number) => Promise.resolve(x), );
await assertRejects( () => assertSpyCallAsync(spyMethod, 0), AssertionError, "spy not called as much as expected", );
await point.action(3, 7); await assertSpyCallAsync(spyMethod, 0); await assertSpyCallAsync(spyMethod, 0, { args: [3, 7], self: point, returned: 3, }); await assertSpyCallAsync(spyMethod, 0, { args: [3, 7], self: point, returned: Promise.resolve(3), }); await assertSpyCallAsync(spyMethod, 0, { args: [3, 7], }); await assertSpyCallAsync(spyMethod, 0, { self: point, }); await assertSpyCallAsync(spyMethod, 0, { returned: 3, }); await assertSpyCallAsync(spyMethod, 0, { returned: Promise.resolve(3), });
await assertRejects( () => assertSpyCallAsync(spyMethod, 0, { args: [7, 4], self: undefined, returned: 7, }), AssertionError, "spy not called with expected args", ); await assertRejects( () => assertSpyCallAsync(spyMethod, 0, { args: [7, 3], }), AssertionError, "spy not called with expected args", ); await assertRejects( () => assertSpyCallAsync(spyMethod, 0, { self: undefined, }), AssertionError, "spy not expected to be called as method on object", ); await assertRejects( () => assertSpyCallAsync(spyMethod, 0, { returned: 7, }), AssertionError, "spy call did not resolve to expected value", ); await assertRejects( () => assertSpyCallAsync(spyMethod, 0, { returned: Promise.resolve(7), }), AssertionError, "spy call did not resolve to expected value", ); await assertRejects( () => assertSpyCallAsync(spyMethod, 1), AssertionError, "spy not called as much as expected", );
await spyMethod(9); await assertSpyCallAsync(spyMethod, 1); await assertSpyCallAsync(spyMethod, 1, { args: [9], self: undefined, returned: 9, }); await assertSpyCallAsync(spyMethod, 1, { args: [9], self: undefined, returned: Promise.resolve(9), }); await assertSpyCallAsync(spyMethod, 1, { args: [9], }); await assertSpyCallAsync(spyMethod, 1, { self: undefined, }); await assertSpyCallAsync(spyMethod, 1, { returned: 9, }); await assertSpyCallAsync(spyMethod, 1, { returned: Promise.resolve(9), });
await assertRejects( () => assertSpyCallAsync(spyMethod, 1, { args: [7, 4], self: point, returned: 7, }), AssertionError, "spy not called with expected args", ); await assertRejects( () => assertSpyCallAsync(spyMethod, 1, { args: [7, 3], }), AssertionError, "spy not called with expected args", ); await assertRejects( () => assertSpyCallAsync(spyMethod, 1, { self: point, }), AssertionError, "spy not called as method on expected self", ); await assertRejects( () => assertSpyCallAsync(spyMethod, 1, { returned: 7, }), AssertionError, "spy call did not resolve to expected value", ); await assertRejects( () => assertSpyCallAsync(spyMethod, 1, { returned: Promise.resolve(7), }), AssertionError, "spy call did not resolve to expected value", ); await assertRejects( () => assertSpyCallAsync(spyMethod, 2), AssertionError, "spy not called as much as expected", );});
Deno.test("assertSpyCallAync on sync value", async () => { const spyFunc: Spy<void> = spy(() => 4);
await spyFunc(); await assertRejects( () => assertSpyCallAsync(spyFunc, 0), AssertionError, "spy call did not return a promise, a value was returned.", );});
Deno.test("assertSpyCallAync on sync error", async () => { const spyFunc: Spy<void> = spy(() => { throw new ExampleError("failed"); });
await assertRejects(() => spyFunc(), ExampleError, "fail"); await assertRejects( () => assertSpyCallAsync(spyFunc, 0), AssertionError, "spy call did not return a promise, an error was thrown.", );});
Deno.test("assertSpyCallAync error", async () => { const spyFunc: Spy<void> = spy(() => Promise.reject(new ExampleError("failed")) );
await assertRejects(() => spyFunc(), ExampleError, "fail"); await assertSpyCallAsync(spyFunc, 0); await assertSpyCallAsync(spyFunc, 0, { args: [], self: undefined, error: { Class: ExampleError, msg: "fail", }, }); await assertSpyCallAsync(spyFunc, 0, { args: [], }); await assertSpyCallAsync(spyFunc, 0, { self: undefined, }); await assertSpyCallAsync(spyFunc, 0, { error: { Class: ExampleError, msg: "fail", }, }); await assertSpyCallAsync(spyFunc, 0, { error: { Class: Error, msg: "fail", }, });
await assertRejects( () => assertSpyCallAsync(spyFunc, 0, { args: [1], self: {}, error: { Class: OtherError, msg: "fail", }, }), AssertionError, "spy not called with expected args", ); await assertRejects( () => assertSpyCallAsync(spyFunc, 0, { args: [1], }), AssertionError, "spy not called with expected args", ); await assertRejects( () => assertSpyCallAsync(spyFunc, 0, { self: {}, }), AssertionError, "spy not called as method on expected self", ); await assertRejects( () => assertSpyCallAsync(spyFunc, 0, { error: { Class: OtherError, msg: "fail", }, }), AssertionError, 'Expected error to be instance of "OtherError"', ); await assertRejects( () => assertSpyCallAsync(spyFunc, 0, { error: { Class: OtherError, msg: "x", }, }), AssertionError, 'Expected error to be instance of "OtherError"', ); await assertRejects( () => assertSpyCallAsync(spyFunc, 0, { error: { Class: ExampleError, msg: "x", }, }), AssertionError, 'Expected error message to include "x", but got "failed".', ); await assertRejects( () => assertSpyCallAsync(spyFunc, 0, { error: { Class: Error, msg: "x", }, }), AssertionError, 'Expected error message to include "x", but got "failed".', ); await assertRejects( () => assertSpyCallAsync(spyFunc, 0, { error: { msg: "x", }, }), AssertionError, 'Expected error message to include "x", but got "failed".', ); await assertRejects( () => assertSpyCallAsync(spyFunc, 0, { returned: 7, }), AssertionError, "spy call returned promise was rejected", ); await assertRejects( () => assertSpyCallAsync(spyFunc, 0, { returned: 7, error: { msg: "x" }, }), TypeError, "do not expect error and return, only one should be expected", ); await assertRejects( () => assertSpyCallAsync(spyFunc, 1), AssertionError, "spy not called as much as expected", );});
Deno.test("assertSpyArg", () => { const spyFunc: Spy<void> = spy();
assertThrows( () => assertSpyCallArg(spyFunc, 0, 0, undefined), AssertionError, "spy not called as much as expected", );
spyFunc(); assertSpyCallArg(spyFunc, 0, 0, undefined); assertSpyCallArg(spyFunc, 0, 1, undefined); assertThrows( () => assertSpyCallArg(spyFunc, 0, 0, 2), AssertionError, "Values are not equal:", );
spyFunc(7, 9); assertSpyCallArg(spyFunc, 1, 0, 7); assertSpyCallArg(spyFunc, 1, 1, 9); assertSpyCallArg(spyFunc, 1, 2, undefined); assertThrows( () => assertSpyCallArg(spyFunc, 0, 0, 9), AssertionError, "Values are not equal:", ); assertThrows( () => assertSpyCallArg(spyFunc, 0, 1, 7), AssertionError, "Values are not equal:", ); assertThrows( () => assertSpyCallArg(spyFunc, 0, 2, 7), AssertionError, "Values are not equal:", );});
Deno.test("assertSpyArgs without range", () => { const spyFunc: Spy<void> = spy();
assertThrows( () => assertSpyCallArgs(spyFunc, 0, []), AssertionError, "spy not called as much as expected", );
spyFunc(); assertSpyCallArgs(spyFunc, 0, []); assertThrows( () => assertSpyCallArgs(spyFunc, 0, [undefined]), AssertionError, "Values are not equal:", ); assertThrows( () => assertSpyCallArgs(spyFunc, 0, [2]), AssertionError, "Values are not equal:", );
spyFunc(7, 9); assertSpyCallArgs(spyFunc, 1, [7, 9]); assertThrows( () => assertSpyCallArgs(spyFunc, 1, [7, 9, undefined]), AssertionError, "Values are not equal:", ); assertThrows( () => assertSpyCallArgs(spyFunc, 1, [9, 7]), AssertionError, "Values are not equal:", );});
Deno.test("assertSpyArgs with start only", () => { const spyFunc: Spy<void> = spy();
assertThrows( () => assertSpyCallArgs(spyFunc, 0, 1, []), AssertionError, "spy not called as much as expected", );
spyFunc(); assertSpyCallArgs(spyFunc, 0, 1, []); assertThrows( () => assertSpyCallArgs(spyFunc, 0, 1, [undefined]), AssertionError, "Values are not equal:", ); assertThrows( () => assertSpyCallArgs(spyFunc, 0, 1, [2]), AssertionError, "Values are not equal:", );
spyFunc(7, 9, 8); assertSpyCallArgs(spyFunc, 1, 1, [9, 8]); assertThrows( () => assertSpyCallArgs(spyFunc, 1, 1, [9, 8, undefined]), AssertionError, "Values are not equal:", ); assertThrows( () => assertSpyCallArgs(spyFunc, 1, 1, [9, 7]), AssertionError, "Values are not equal:", );});
Deno.test("assertSpyArgs with range", () => { const spyFunc: Spy<void> = spy();
assertThrows( () => assertSpyCallArgs(spyFunc, 0, 1, 3, []), AssertionError, "spy not called as much as expected", );
spyFunc(); assertSpyCallArgs(spyFunc, 0, 1, 3, []); assertThrows( () => assertSpyCallArgs(spyFunc, 0, 1, 3, [undefined, undefined]), AssertionError, "Values are not equal:", ); assertThrows( () => assertSpyCallArgs(spyFunc, 0, 1, 3, [2, 4]), AssertionError, "Values are not equal:", );
spyFunc(7, 9, 8, 5, 6); assertSpyCallArgs(spyFunc, 1, 1, 3, [9, 8]); assertThrows( () => assertSpyCallArgs(spyFunc, 1, 1, 3, [9, 8, undefined]), AssertionError, "Values are not equal:", ); assertThrows( () => assertSpyCallArgs(spyFunc, 1, 1, 3, [9, 7]), AssertionError, "Values are not equal:", );});