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

Function assertIgnoreOptions

testing/bdd_test.ts:1094–1128  ·  view source on GitHub ↗

* Asserts that `Deno.test` is called with the correct options for the `describe` call in the callback function. * This is used to reduce code duplication when testing calling `describe` with different call signatures.

(
      expectedOptions: Omit<Deno.TestDefinition, "name" | "fn">,
      cb: (fns: readonly [Spy, Spy]) => void,
    )

Source from the content-addressed store, hash-verified

1092 * This is used to reduce code duplication when testing calling `describe` with different call signatures.
1093 */
1094 async function assertIgnoreOptions(
1095 expectedOptions: Omit<Deno.TestDefinition, "name" | "fn">,
1096 cb: (fns: readonly [Spy, Spy]) => void,
1097 ) {
1098 using test = stub(Deno, "test");
1099 const fns = [spy(), spy()] as const;
1100 try {
1101 cb(fns);
1102 assertSpyCall(test, 0);
1103 const call = test.calls[0];
1104 const options = call?.args[0] as Deno.TestDefinition;
1105 assertEquals(
1106 Object.keys(options).sort(),
1107 ["name", "fn", ...Object.keys(expectedOptions)].sort(),
1108 );
1109 assertObjectMatch(options, {
1110 name: "example",
1111 ...expectedOptions,
1112 });
1113
1114 assertSpyCalls(fns[0], 0);
1115 assertSpyCalls(fns[1], 0);
1116
1117 const context = new TestContext("example");
1118 const result = options.fn(context);
1119 assertStrictEquals(Promise.resolve(result), result);
1120 assertEquals(await result, undefined);
1121 assertSpyCalls(context.spies.step, 0);
1122
1123 assertSpyCalls(fns[0], 0);
1124 assertSpyCalls(fns[1], 0);
1125 } finally {
1126 TestSuiteInternal.reset();
1127 }
1128 }
1129 /**
1130 * Asserts that `Deno.test` is called with just the name, ignore, and function for the `describe.ignore` call in the callback function.
1131 * In addition to that, it asserts that the individual test cases registered with `it` use the test step API correctly.

Callers 2

assertMinimumOptionsFunction · 0.85
assertAllOptionsFunction · 0.85

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