File tree 2 files changed +11
-3
lines changed
2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,15 @@ describe('include', () => {
8
8
cb2 = jest . fn ( ( ) => false ) ;
9
9
} ) ;
10
10
11
+ describe ( 'When not passing a string fieldName' , ( ) => {
12
+ it ( 'Should throw an error' , ( ) => {
13
+ // @ts -ignore
14
+ expect ( ( ) => vest . include ( { } ) ) . toThrow ( ) ;
15
+ // @ts -ignore
16
+ expect ( ( ) => vest . include ( undefined ) ) . toThrow ( ) ;
17
+ } ) ;
18
+ } ) ;
19
+
11
20
describe ( 'There is an `onlyd` field' , ( ) => {
12
21
describe ( '`include` is run as-is without modifiers' , ( ) => {
13
22
it ( 'Should run the included test along with the onlyd test' , ( ) => {
Original file line number Diff line number Diff line change 1
1
import defaultTo from 'defaultTo' ;
2
2
import hasOwnProperty from 'hasOwnProperty' ;
3
+ import invariant from 'invariant' ;
3
4
import { isStringValue } from 'isStringValue' ;
4
5
import optionalFunctionValue from 'optionalFunctionValue' ;
5
6
@@ -14,9 +15,7 @@ export default function include(fieldName: string): {
14
15
const context = ctx . useX ( ) ;
15
16
const { inclusion, exclusion } = context ;
16
17
17
- if ( ! fieldName ) {
18
- return { when } ;
19
- }
18
+ invariant ( isStringValue ( fieldName ) ) ;
20
19
21
20
inclusion [ fieldName ] = defaultTo ( exclusion . tests [ fieldName ] , true ) ;
22
21
You can’t perform that action at this time.
0 commit comments