2020-01-02 15:13:47 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-02-11 17:24:27 +01:00
|
|
|
const { test } = Deno;
|
2019-03-28 17:31:15 +01:00
|
|
|
import { assertEquals, assert } from "../testing/asserts.ts";
|
|
|
|
import { deepAssign } from "./deep_assign.ts";
|
|
|
|
|
2020-04-28 12:33:09 +02:00
|
|
|
test("deepAssignTest", function (): void {
|
2019-03-28 17:31:15 +01:00
|
|
|
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"),
|
2020-03-29 04:03:49 +11:00
|
|
|
bar: "deno",
|
2019-03-28 17:31:15 +01:00
|
|
|
},
|
|
|
|
deno: { bar: { deno: ["is", "not", "node"] } },
|
2020-03-29 04:03:49 +11:00
|
|
|
reg: RegExp(/DENOWOWO/),
|
2019-03-28 17:31:15 +01:00
|
|
|
};
|
|
|
|
assert(date !== expected.foo.deno);
|
|
|
|
assert(reg !== expected.reg);
|
|
|
|
assertEquals(actual, expected);
|
|
|
|
});
|