-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from KorzhCom/dev
Version 1.5.3
- Loading branch information
Showing
18 changed files
with
335 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { expect, test } from 'vitest' | ||
import {utils} from "../src/public_api" | ||
|
||
test('should deeply assign properties from source to target', () => { | ||
const source = { | ||
scalar: 'value', | ||
refObject: { | ||
nested: 'nestedValue', | ||
array: [1, 2, 3], | ||
html: document.createElement('div'), | ||
}, | ||
refArray: [{nested: 'nestedValue'}, 1, 'two'], | ||
refArrayRef: [{nested: 'nestedValueRef'}, 1, 'two'], | ||
htmlRef: document.createElement('div'), | ||
}; | ||
|
||
// @ts-ignore | ||
source.refArray[3] = source.refArray; | ||
|
||
const target = utils.assignDeep({}, source); | ||
|
||
expect(target).toEqual({ | ||
scalar: 'value', | ||
refObject: { | ||
nested: 'nestedValue', | ||
array: [1, 2, 3], | ||
html: document.createElement('div'), | ||
}, | ||
refArray: [{nested: 'nestedValue'}, 1, 'two', target.refArray], | ||
refArrayRef: [{nested: 'nestedValueRef'}, 1, 'two'], | ||
htmlRef: document.createElement('div'), | ||
}); | ||
expect(target.refObject).not.toBe(source.refObject); | ||
expect(target.refObject.html).toBe(source.refObject.html); | ||
expect(target.refArray[0]).toBe(source.refArray[0]); | ||
expect(target.refArray[3]).toBe(source.refArray); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,4 @@ | |
"files": [ | ||
"dist" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.