-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: tests for
clean
and recursive behavior resolved
- Loading branch information
1 parent
65452ce
commit 88241e9
Showing
3 changed files
with
108 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { Chance } from 'chance'; | ||
import { clean } from '../../../src/serializers/utils/clean'; | ||
|
||
describe('`clean`', () => { | ||
let chance: Chance.Chance; | ||
|
||
beforeEach(() => { | ||
chance = new Chance(); | ||
}); | ||
|
||
it('should return an empty object when given an empty object', () => { | ||
const result = clean({}); | ||
|
||
expect(result).toEqual({}); | ||
}); | ||
|
||
it('should removed undefined values from the given object', () => { | ||
const object = { | ||
a: chance.string(), | ||
b: undefined, | ||
}; | ||
|
||
const result = clean(object); | ||
|
||
expect(result).toEqual({ | ||
a: object.a, | ||
}); | ||
}); | ||
|
||
it('should remove undefined values, recursively, from the given object', () => { | ||
const object = { | ||
a: { | ||
b: undefined, | ||
}, | ||
c: chance.string(), | ||
}; | ||
|
||
const result = clean(object); | ||
|
||
expect(result).toEqual({ | ||
c: object.c, | ||
}); | ||
}); | ||
|
||
it('should remove empty objects from the given object', () => { | ||
const object = { | ||
a: {}, | ||
b: chance.string(), | ||
}; | ||
|
||
const result = clean(object); | ||
|
||
expect(result).toEqual({ | ||
b: object.b, | ||
}); | ||
}); | ||
|
||
it('should remove empty objects, recursively, from the given object', () => { | ||
const object = { | ||
a: { | ||
b: {}, | ||
}, | ||
c: chance.string(), | ||
}; | ||
|
||
const result = clean(object); | ||
|
||
expect(result).toEqual({ | ||
c: object.c, | ||
}); | ||
}); | ||
|
||
it('should remove empty arrays from the given object', () => { | ||
const object = { | ||
a: [], | ||
b: chance.string(), | ||
}; | ||
|
||
const result = clean(object); | ||
|
||
expect(result).toEqual({ | ||
b: object.b, | ||
}); | ||
}); | ||
|
||
it('should remove empty arrays, recursively, from the given object', () => { | ||
const object = { | ||
a: { | ||
b: [], | ||
}, | ||
c: chance.string(), | ||
}; | ||
|
||
const result = clean(object); | ||
|
||
expect(result).toEqual({ | ||
c: object.c, | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './assertMetadataIsPresent'; | ||
export * from './getMetadataBySymbol'; | ||
export * from './collect'; | ||
export * from './clean'; |