1
0
mirror of https://github.com/dzeiocom/libs.git synced 2025-06-16 04:29:21 +00:00

Updated objectSort to support an Array containing a specific order

Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
2021-04-11 00:34:14 +02:00
parent 485e3b7b36
commit 76e2263812
3 changed files with 29 additions and 5 deletions

View File

@ -52,7 +52,7 @@ describe('Object Keys Tests', () => {
})
})
describe('Object Sort Tests', () => {
describe('Object Size Tests', () => {
it('shoud return length of the object', () => {
const obj = {
index0: true,
@ -82,6 +82,20 @@ describe('Object sort Tests', () => {
b: 'first'
})
})
it('should sort by the specified key', () => {
const obj = {
b: 'first',
a: 'second',
c: 'zero',
d: 'fourth'
}
expect(objectSort(obj, ['c', 'a'])).toEqual({
c: 'zero',
a: 'second',
b: 'first',
d: 'fourth'
})
})
})
describe('Object Clone Tests', () => {