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

Function assertItOptions

testing/_test_helpers.ts:117–153  ·  view source on GitHub ↗
(
  expectedOptions: Omit<Deno.TestDefinition, "name" | "fn">,
  cb: (fn: Spy) => void,
)

Source from the content-addressed store, hash-verified

115}
116
117async 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
155export async function assertMinimumItOptions(
156 cb: (fn: Spy) => void,

Callers 1

assertMinimumItOptionsFunction · 0.85

Calls 9

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

Tested by

no test coverage detected