-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into remove-empty-cat-filter
- Loading branch information
Showing
10 changed files
with
298 additions
and
118 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Jest unit tests | ||
name: Codi unit tests | ||
|
||
on: | ||
push: | ||
|
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
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
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
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,81 @@ | ||
import { describe, it, assertEqual } from 'codi-test-framework'; | ||
import mergeDeep from '../../../mod/utils/merge.js' | ||
|
||
describe('mergeDeep Module', () => { | ||
|
||
it('should merge objects deeply', () => { | ||
const target = { | ||
name: 'Rob', | ||
age: 28, | ||
address: { | ||
street: '6 fourteenth street', | ||
city: 'Johannesburg', | ||
}, | ||
hobbies: ['squash', 'guitar'], | ||
}; | ||
|
||
const source = { | ||
name: 'Rob', | ||
age: 28, | ||
address: { | ||
street: '6 fourteenth street', | ||
city: 'Johannesburg', | ||
}, | ||
hobbies: ['cooking'], | ||
}; | ||
|
||
const expected = { | ||
name: 'Rob', | ||
age: 28, | ||
address: { | ||
street: '6 fourteenth street', | ||
city: 'Johannesburg', | ||
}, | ||
hobbies: ['squash', 'guitar', 'cooking'], | ||
}; | ||
|
||
const mergedObj = mergeDeep(target, source); | ||
|
||
assertEqual(mergedObj, expected) | ||
}); | ||
|
||
it('should merge arrays deeply', () => { | ||
const target = { | ||
fruits: ['apple', 'banana'], | ||
}; | ||
|
||
const source = { | ||
fruits: ['banana', 'orange'], | ||
}; | ||
|
||
const expected = { | ||
fruits: ['apple', 'banana','banana', 'orange'], | ||
}; | ||
|
||
const mergedObj = mergeDeep(target, source); | ||
|
||
assertEqual(mergedObj, expected) | ||
}); | ||
|
||
it('should handle merging with null or undefined values', () => { | ||
const target = { | ||
name: 'John', | ||
age: 30, | ||
}; | ||
|
||
const source1 = null; | ||
const source2 = undefined; | ||
|
||
const expected = { | ||
name: 'John', | ||
age: 30, | ||
}; | ||
|
||
const mergedObj1 = mergeDeep(target, source1); | ||
const mergedObj2 = mergeDeep(target, source2); | ||
|
||
assertEqual(mergedObj1, expected); | ||
assertEqual(mergedObj2, expected); | ||
}); | ||
|
||
}); |
Oops, something went wrong.