From a8850434a675edf516c648ee529983149210e34d Mon Sep 17 00:00:00 2001 From: Valentin Kunz Date: Tue, 6 Sep 2022 17:46:15 +0200 Subject: [PATCH] utils: add use-case showing deepAssign does not replace, but merges --- lib/common/spec/utils.spec.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/common/spec/utils.spec.js b/lib/common/spec/utils.spec.js index 7952170e..67794147 100644 --- a/lib/common/spec/utils.spec.js +++ b/lib/common/spec/utils.spec.js @@ -1,7 +1,7 @@ import { RoutifyRuntime } from '../../runtime/Instance/RoutifyRuntime.js' import { RoutifyBuildtime } from '../../buildtime/RoutifyBuildtime.js' -import { mockRoutes, next } from '../utils.js' +import { deepAssign, mockRoutes, next } from '../utils.js' import { writable } from 'svelte/store' test('mock routes', () => { @@ -66,6 +66,25 @@ test('next store value', () => { }) }) +test('deepAssign replaces previous properties', () => { + const defaults = { + routifyDir: { + default: "src/routes" + } + }; + + const options = { + routifyDir: { + "bar": "src/routes/bar", + "foo": "src/routes/foo" + } + }; + + const assigned = deepAssign({}, defaults, options); + + assert.equal(options, assigned); +}) + // test('resolveValues', () => { // const obj = { // plan: { text: 'nothing to see here' },