deno.land / std@0.166.0 / testing / mock_examples / internals_injection_test.ts

internals_injection_test.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.import { assertSpyCall, assertSpyCalls, spy } from "../mock.ts";import { assertEquals } from "../asserts.ts";import { _internals, square } from "./internals_injection.ts";
Deno.test("square calls multiply and returns results", () => { const multiplySpy = spy(_internals, "multiply");
try { assertEquals(square(5), 25); } finally { // unwraps the multiply method on the _internals object multiplySpy.restore(); }
// asserts that multiplySpy was called at least once and details about the first call. assertSpyCall(multiplySpy, 0, { args: [5, 5], returned: 25, });
// asserts that multiplySpy was only called once. assertSpyCalls(multiplySpy, 1);});
std

Version Info

Tagged at
a year ago