MCPcopy Index your code
hub / github.com/oakserver/oak / createMockApp

Function createMockApp

testing.ts:25–56  ·  view source on GitHub ↗
(
  state: S = {} as S,
)

Source from the content-addressed store, hash-verified

23
24/** Creates a mock of `Application`. */
25export function createMockApp<
26 S extends Record<PropertyKey, any> = Record<string, any>,
27>(
28 state: S = {} as S,
29): Application<S> {
30 const app = {
31 state,
32 use() {
33 return app;
34 },
35 [Symbol.for("Deno.customInspect")]() {
36 return "MockApplication {}";
37 },
38 [Symbol.for("nodejs.util.inspect.custom")](
39 depth: number,
40 options: any,
41 inspect: (value: unknown, options?: unknown) => string,
42 ) {
43 if (depth < 0) {
44 return options.stylize(`[MockApplication]`, "special");
45 }
46
47 const newOptions = Object.assign({}, options, {
48 depth: options.depth === null ? null : options.depth - 1,
49 });
50 return `${options.stylize("MockApplication", "special")} ${
51 inspect({}, newOptions)
52 }`;
53 },
54 } as any;
55 return app;
56}
57
58/** Options that can be set in a mock context. */
59export interface MockContextOptions<

Callers 6

fnFunction · 0.90
setupFunction · 0.90
fnFunction · 0.90
setupFunction · 0.90
setupFunction · 0.90
createMockContextFunction · 0.70

Calls

no outgoing calls

Tested by 5

fnFunction · 0.72
setupFunction · 0.72
fnFunction · 0.72
setupFunction · 0.72
setupFunction · 0.72