Skip to content

Commit

Permalink
fix: chaning Date to objects in flat.set error
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtek-krysiak committed Oct 24, 2020
1 parent 478af85 commit 291cb83
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/utils/flat/set.spec.ts
Expand Up @@ -33,14 +33,22 @@ describe('module:flat.set', () => {
context('passing basic types', () => {
const newPropertyName = 'newProperty'

it('does not change the record when regular file is set', function () {
it('does not change the type when regular file is set', function () {
const file = new File([], 'amazing.me')

newParams = set(params, newPropertyName, file)

expect(newParams[newPropertyName]).to.equal(file)
})

it('does not change the type when Date is set', () => {
const date = new Date()

newParams = set(params, newPropertyName, date)

expect(newParams[newPropertyName]).to.equal(date)
})

it('sets null', () => {
expect(set(params, newPropertyName, null)).to.have.property(newPropertyName, null)
})
Expand Down
2 changes: 1 addition & 1 deletion src/utils/flat/set.ts
Expand Up @@ -30,7 +30,7 @@ const set = (params: FlattenParams = {}, propertyPath: string, value?: any): Fla
.reduce((memo, key) => ({ ...memo, [key]: params[key] }), {} as FlattenParams)

if (typeof value !== 'undefined') {
if (isObject(value)) {
if (isObject(value) && !(value instanceof Date)) {
const flattened = flatten(value) as any

if (Object.keys(flattened).length) {
Expand Down

0 comments on commit 291cb83

Please sign in to comment.