File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -200,8 +200,10 @@ describe('Shared utils', () => {
200
200
} ) ;
201
201
202
202
describe ( 'isEmptyArray' , ( ) => {
203
- it ( 'should return true when array is empty' , ( ) => {
203
+ it ( 'should return true when array is empty or not exists ' , ( ) => {
204
204
expect ( isEmptyArray ( [ ] ) ) . to . be . true ;
205
+ expect ( isEmptyArray ( null ) ) . to . be . true ;
206
+ expect ( isEmptyArray ( undefined ) ) . to . be . true ;
205
207
} ) ;
206
208
207
209
it ( 'should return false when array is not empty' , ( ) => {
@@ -211,8 +213,6 @@ describe('Shared utils', () => {
211
213
} ) ;
212
214
213
215
it ( 'should return false for non-array values' , ( ) => {
214
- expect ( isEmptyArray ( null ) ) . to . be . false ;
215
- expect ( isEmptyArray ( undefined ) ) . to . be . false ;
216
216
expect ( isEmptyArray ( { } ) ) . to . be . false ;
217
217
expect ( isEmptyArray ( '' ) ) . to . be . false ;
218
218
expect ( isEmptyArray ( 0 ) ) . to . be . false ;
Original file line number Diff line number Diff line change @@ -55,10 +55,10 @@ export const isNil = (val: unknown): val is null | undefined =>
55
55
isUndefined ( val ) || val === null ;
56
56
57
57
export const isEmptyArray = ( array : unknown ) : boolean => {
58
- if ( ! Array . isArray ( array ) ) {
59
- return false ;
58
+ if ( isNil ( array ) ) {
59
+ return true ;
60
60
}
61
- return array . length === 0 ;
61
+ return Array . isArray ( array ) && array . length === 0 ;
62
62
} ;
63
63
64
64
export const isSymbol = ( val : unknown ) : val is symbol =>
You can’t perform that action at this time.
0 commit comments