Skip to content

Commit

Permalink
utils: add use-case showing deepAssign does not replace, but merges
Browse files Browse the repository at this point in the history
  • Loading branch information
vkunz committed Sep 6, 2022
1 parent d673c0e commit a885043
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/common/spec/utils.spec.js
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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' },
Expand Down

0 comments on commit a885043

Please sign in to comment.