mirror of
https://github.com/denoland/deno.git
synced 2025-09-30 06:04:48 +00:00
parent
8f0407efad
commit
13aeee460a
21 changed files with 1072 additions and 0 deletions
24
util/deep_assign_test.ts
Normal file
24
util/deep_assign_test.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { test } from "../testing/mod.ts";
|
||||
import { assertEquals, assert } from "../testing/asserts.ts";
|
||||
import { deepAssign } from "./deep_assign.ts";
|
||||
|
||||
test(function deepAssignTest() {
|
||||
const date = new Date("1979-05-27T07:32:00Z");
|
||||
const reg = RegExp(/DENOWOWO/);
|
||||
const obj1 = { deno: { bar: { deno: ["is", "not", "node"] } } };
|
||||
const obj2 = { foo: { deno: date } };
|
||||
const obj3 = { foo: { bar: "deno" }, reg: reg };
|
||||
const actual = deepAssign(obj1, obj2, obj3);
|
||||
const expected = {
|
||||
foo: {
|
||||
deno: new Date("1979-05-27T07:32:00Z"),
|
||||
bar: "deno"
|
||||
},
|
||||
deno: { bar: { deno: ["is", "not", "node"] } },
|
||||
reg: RegExp(/DENOWOWO/)
|
||||
};
|
||||
assert(date !== expected.foo.deno);
|
||||
assert(reg !== expected.reg);
|
||||
assertEquals(actual, expected);
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue