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

parameter_injection_test.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.import { assertSpyCall, assertSpyCalls, spy } from "../mock.ts";import { assertEquals } from "../asserts.ts";import { multiply, square } from "./parameter_injection.ts";
Deno.test("square calls multiply and returns results", () => { const multiplySpy = spy(multiply);
assertEquals(square(multiplySpy, 5), 25);
// 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