Skip to content

Commit

Permalink
fix pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Jun 5, 2022
1 parent 2a0533b commit 1b4633a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/core/tests/utils.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
matchMutation,
scheduleMicrotask,
sleep,
isPlainArray,
} from '../utils'
import { Mutation } from '../mutation'
import { createQueryClient } from '../../tests/utils'
Expand Down Expand Up @@ -56,6 +57,16 @@ describe('core/utils', () => {
})
})

describe('isPlainArray', () => {
it('should return `true` for plain arrays', () => {
expect(isPlainArray([1, 2])).toEqual(true)
})

it('should return `false` for non plain arrays', () => {
expect(isPlainArray(Object.assign([1, 2], { a: 'b' }))).toEqual(false)
})
})

describe('partialDeepEqual', () => {
it('should return `true` if a includes b', () => {
const a = { a: { b: 'b' }, c: 'c', d: [{ d: 'd ' }] }
Expand Down
4 changes: 2 additions & 2 deletions src/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ export function shallowEqualObjects<T>(a: T, b: T): boolean {
return true
}

export function isPlainArray(a: any) {
return Array.isArray(a) && a.length === Object.keys(a).length
export function isPlainArray(value: unknown) {
return Array.isArray(value) && value.length === Object.keys(value).length
}

// Copied from: https://github.com/jonschlinkert/is-plain-object
Expand Down

0 comments on commit 1b4633a

Please sign in to comment.