MCPcopy Create free account
hub / github.com/denoland/std / assertDescribeOptions

Function assertDescribeOptions

testing/_test_helpers.ts:74–109  ·  view source on GitHub ↗
(
  expectedOptions: Omit<Deno.TestDefinition, "name" | "fn">,
  cb: (fns: readonly [Spy, Spy]) => void,
)

Source from the content-addressed store, hash-verified

72}
73
74async function assertDescribeOptions(
75 expectedOptions: Omit<Deno.TestDefinition, "name" | "fn">,
76 cb: (fns: readonly [Spy, Spy]) => void,
77) {
78 using test = stub(Deno, "test");
79 const fns = [spy(), spy()] as const;
80 try {
81 cb(fns);
82
83 assertSpyCall(test, 0);
84 const call = test.calls[0];
85 const options = call?.args[0] as Deno.TestDefinition;
86 assertEquals(
87 Object.keys(options).sort(),
88 ["name", "fn", ...Object.keys(expectedOptions)].sort(),
89 );
90 assertObjectMatch(options, {
91 name: "example",
92 ...expectedOptions,
93 });
94
95 assertSpyCalls(fns[0], 0);
96 assertSpyCalls(fns[1], 0);
97
98 const context = new TestContext("example");
99 const result = options.fn(context);
100
101 assertStrictEquals(Promise.resolve(result), result);
102 assertEquals(await result, undefined);
103 assertSpyCalls(context.spies.step, 0);
104 assertSpyCalls(fns[0], 0);
105 assertSpyCalls(fns[1], 0);
106 } finally {
107 TestSuiteInternal.reset();
108 }
109}
110
111export async function assertMinimumDescribeOptions(
112 cb: (fn: readonly [Spy, Spy]) => void,

Callers 1

Calls 9

stubFunction · 0.90
spyFunction · 0.90
assertSpyCallFunction · 0.90
assertEqualsFunction · 0.90
assertObjectMatchFunction · 0.90
assertSpyCallsFunction · 0.90
assertStrictEqualsFunction · 0.90
keysMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected