File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
src/rules-engine/operators Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ export default {
8
8
}
9
9
10
10
// Verify empty/filled objects
11
- if ( typeof data === 'object' ) {
11
+ if ( typeof data === 'object' && data !== null ) {
12
12
const hasKeys = Object . keys ( data ) . length
13
13
return shouldBeEmpty ? hasKeys === 0 : hasKeys > 0
14
14
}
Original file line number Diff line number Diff line change @@ -26,5 +26,20 @@ describe('Common Operators', () => {
26
26
test ( 'Should fail given a filled object' , ( ) => {
27
27
expect ( CommonOperators . isEmpty ( { key : 'one' } , true ) ) . toBeFalsy ( )
28
28
} )
29
+ test ( 'Should fail given a null value' , ( ) => {
30
+ expect ( CommonOperators . isEmpty ( null , true ) ) . toBeFalsy ( )
31
+ } )
32
+ test ( 'Should fail given an undefined value' , ( ) => {
33
+ expect ( CommonOperators . isEmpty ( undefined , true ) ) . toBeFalsy ( )
34
+ } )
35
+ test ( 'Should fail given an integer' , ( ) => {
36
+ expect ( CommonOperators . isEmpty ( 33 , true ) ) . toBeFalsy ( )
37
+ } )
38
+ test ( 'Should fail given a string' , ( ) => {
39
+ expect ( CommonOperators . isEmpty ( 'string' , true ) ) . toBeFalsy ( )
40
+ } )
41
+ test ( 'Should fail given a boolean' , ( ) => {
42
+ expect ( CommonOperators . isEmpty ( true , true ) ) . toBeFalsy ( )
43
+ } )
29
44
} )
30
45
} )
You can’t perform that action at this time.
0 commit comments