File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,19 @@ describe('Party Tests', () => {
50
50
51
51
expect (mock .getPartyType ()).toBe (' west coast party' );
52
52
});
53
- });
53
+
54
+ test (' throwing an error if we forget to specify the return value' )
55
+ const mock = mock <PartyProvider >(
56
+ {},
57
+ {
58
+ fallbackMockImplementation : () => {
59
+ throw new Error (' not mocked' );
60
+ },
61
+ }
62
+ );
63
+
64
+ expect (() => mock .getPartyType ()).toThrowError (' not mocked' );
65
+ });
54
66
```
55
67
56
68
## Assigning Mocks with a Type
Original file line number Diff line number Diff line change @@ -124,6 +124,19 @@ describe('jest-mock-extended', () => {
124
124
expect ( mockObj . getSomethingWithArgs ( 1 , 2 ) ) . toBe ( 1 ) ;
125
125
} ) ;
126
126
127
+ test ( 'Can specify fallbackMockImplementation' , ( ) => {
128
+ const mockObj = mock < MockInt > (
129
+ { } ,
130
+ {
131
+ fallbackMockImplementation : ( ) => {
132
+ throw new Error ( 'not mocked' ) ;
133
+ } ,
134
+ }
135
+ ) ;
136
+
137
+ expect ( ( ) => mockObj . getSomethingWithArgs ( 1 , 2 ) ) . toThrowError ( 'not mocked' ) ;
138
+ } ) ;
139
+
127
140
test ( 'Can specify multiple calledWith' , ( ) => {
128
141
const mockObj = mock < MockInt > ( ) ;
129
142
mockObj . getSomethingWithArgs . calledWith ( 1 , 2 ) . mockReturnValue ( 3 ) ;
You can’t perform that action at this time.
0 commit comments