deno.land / std@0.166.0 / collections / sample_test.ts

sample_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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
import { assert, assertEquals } from "../testing/asserts.ts";import { sample } from "./sample.ts";
Deno.test({ name: "[collections/sample] no mutation", fn() { const array = ["a", "abc", "ba"]; sample(array);
assertEquals(array, ["a", "abc", "ba"]); },});
Deno.test({ name: "[collections/sample] empty input", fn() { const actual = sample([]); assertEquals(actual, undefined); },});
Deno.test({ name: "[collections/sample] array of number", fn() { const input = [1, 2, 3]; const actual = sample([1, 2, 3]);
assert(actual && input.includes(actual)); },});
Deno.test({ name: "[collections/sample] array of objects", fn() { const input = [ { name: "Anna", age: 18, }, { name: "Kim", age: 24, }, ]; const actual = sample(input);
assert(actual && input.includes(actual)); },});
std
Deno standard library
GitHub Repositorydenoland/deno_std
GitHub Stars
2458

Version Info

Tagged at
2 months ago