mirror of
https://github.com/denoland/std.git
synced 2024-11-22 04:59:05 +00:00
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
import { assertEquals, assertNotStrictEquals } from "@std/assert";
|
|
import { pick } from "./pick.ts";
|
|
|
|
Deno.test({
|
|
name: "pick() returns a new empty object when no keys are provided",
|
|
fn() {
|
|
const obj = { a: 5, b: 6, c: 7, d: 8 };
|
|
const picked = pick(obj, []);
|
|
|
|
assertEquals(picked, {});
|
|
assertNotStrictEquals(picked, obj);
|
|
},
|
|
});
|
|
|
|
Deno.test({
|
|
name:
|
|
"pick() returns a new object from the provided object with the provided keys",
|
|
fn() {
|
|
const obj = { a: 5, b: 6, c: 7, d: 8 };
|
|
const picked = pick(obj, ["a", "c"]);
|
|
|
|
assertEquals(picked, { a: 5, c: 7 });
|
|
assertNotStrictEquals(picked, obj);
|
|
},
|
|
});
|
|
|
|
Deno.test({
|
|
name:
|
|
"pick() returns a new object from the provided object with the provided keys (all keys are provided)",
|
|
fn() {
|
|
const obj = { a: 5, b: 6, c: 7, d: 8 };
|
|
const picked = pick(obj, ["a", "b", "c", "d"]);
|
|
|
|
assertEquals(picked, { a: 5, b: 6, c: 7, d: 8 });
|
|
assertNotStrictEquals(picked, obj);
|
|
},
|
|
});
|