1
1
import { Maybe } from '@/src/maybe' ;
2
2
import { Result } from '@/src/result' ;
3
3
import { FunctionOfT , isDefined , isFunction } from '@/src/utilities' ;
4
+ import { equals } from '@jest/expect-utils' ;
4
5
5
6
expect . extend ( {
6
7
toHaveNoValue < TValue > ( received : Maybe < TValue > ) : MatchResponse {
@@ -25,7 +26,7 @@ expect.extend({
25
26
26
27
const value = received . getValueOrThrow ( ) ;
27
28
28
- return value === expectedValue
29
+ return equals ( value , expectedValue )
29
30
? r (
30
31
true ,
31
32
`expected [${ received } ] to have a value [${ expectedValue } ], but it has a value of [${ value } ]`
@@ -66,17 +67,15 @@ expect.extend({
66
67
67
68
const value = received . getValueOrThrow ( ) ;
68
69
69
- if ( expectedValue === value ) {
70
- return r (
71
- true ,
72
- `expected [${ received } ] to be successful but not have value [${ expectedValue } ] but it did`
73
- ) ;
74
- }
75
-
76
- return r (
77
- false ,
78
- `expected [${ received } ] to have value [${ expectedValue } ], but found value [${ value } ]`
79
- ) ;
70
+ return equals ( expectedValue , value )
71
+ ? r (
72
+ true ,
73
+ `expected [${ received } ] to be successful but not have value [${ expectedValue } ] but it did`
74
+ )
75
+ : r (
76
+ false ,
77
+ `expected [${ received } ] to have value [${ expectedValue } ], but found value [${ value } ]`
78
+ ) ;
80
79
} ,
81
80
toFail < TValue , TError > ( received : Result < TValue , TError > ) {
82
81
return received . isSuccess
0 commit comments