@@ -108,20 +108,24 @@ describe('Object', () => {
108108 } ) ;
109109
110110 describe ( 'P.object.exact({...})' , ( ) => {
111- it ( 'should only catch the literal `{}` .' , ( ) => {
111+ it ( 'should only catch exact match .' , ( ) => {
112112 const fn = ( input : object ) =>
113113 match ( input )
114114 . with ( P . object . exact ( { a : P . any } ) , ( obj ) => {
115115 type t = Expect < Equal < typeof obj , { a : unknown } > > ;
116116 return 'yes' ;
117117 } )
118- // @ts -expect-error: non empty object aren't caught
119- . exhaustive ( ) ;
120- expect ( fn ( { } ) ) . toEqual ( 'yes' ) ;
121- expect ( ( ) => fn ( { hello : 'world' } ) ) . toThrow ( ) ;
122- expect ( ( ) => fn ( ( ) => { } ) ) . toThrow ( ) ;
123- expect ( ( ) => fn ( [ 1 , 2 , 3 ] ) ) . toThrow ( ) ;
124- expect ( ( ) => fn ( [ ] ) ) . toThrow ( ) ;
118+ . otherwise ( ( ) => 'no' ) ;
119+
120+ expect ( fn ( { a : [ ] } ) ) . toEqual ( 'yes' ) ;
121+ expect ( fn ( { a : null } ) ) . toEqual ( 'yes' ) ;
122+ expect ( fn ( { a : undefined } ) ) . toEqual ( 'yes' ) ;
123+ expect ( fn ( { a : undefined , b :undefined } ) ) . toEqual ( 'no' ) ;
124+ expect ( fn ( { } ) ) . toEqual ( 'no' ) ;
125+ expect ( ( ) => fn ( { hello : 'world' } ) ) . toEqual ( 'no' ) ;
126+ expect ( ( ) => fn ( ( ) => { } ) ) . toEqual ( 'no' ) ;
127+ expect ( ( ) => fn ( [ 1 , 2 , 3 ] ) ) . toEqual ( 'no' ) ;
128+ expect ( ( ) => fn ( [ ] ) ) . toEqual ( 'no' ) ;
125129 } ) ;
126130 } ) ;
127131} ) ;
0 commit comments