From 4ab00481158fc1760c9bf21fc29664c0de4f3e37 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 13 Sep 2019 22:00:39 +0200 Subject: [PATCH] Tests for merging. --- src/Squidex/app/framework/utils/types.spec.ts | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/Squidex/app/framework/utils/types.spec.ts b/src/Squidex/app/framework/utils/types.spec.ts index 68cbb4613..eeeef1153 100644 --- a/src/Squidex/app/framework/utils/types.spec.ts +++ b/src/Squidex/app/framework/utils/types.spec.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Types } from './types'; +import { mergeInto, Types } from './types'; describe('Types', () => { it('should calculate hash string', () => { @@ -152,6 +152,39 @@ describe('Types', () => { it('should treat object of empty values as empty', () => { expect(Types.isEmpty({ a: null, b: null })).toBeTruthy(); }); + + it('should merge deeply', () => { + const source = {}; + + mergeInto(source, { + rootShared: 1, + rootA: 2, + nested: { + a: 3 + }, + array: [4] + }); + + mergeInto(source, { + rootShared: 5, + rootB: 6, + nested: { + b: 7 + }, + array: [8] + }); + + expect(source).toEqual({ + rootShared: 5, + rootA: 2, + rootB: 6, + nested: { + a: 3, + b: 7 + }, + array: [4, 8] + }); + }); }); class MyClass {