@@ -51,13 +51,13 @@ test('stubbing with vitest-when', () => {
51
51
when (stub ).calledWith (1 , 2 , 3 ).thenReturn (4 );
52
52
when (stub ).calledWith (4 , 5 , 6 ).thenReturn (7 );
53
53
54
- const result123 = stub (1 , 2 , 3 );
54
+ let result = stub (1 , 2 , 3 );
55
55
expect (result ).toBe (4 );
56
56
57
- const result456 = stub (4 , 5 , 6 );
57
+ result = stub (4 , 5 , 6 );
58
58
expect (result ).toBe (7 );
59
59
60
- const result789 = stub (7 , 8 , 9 );
60
+ result = stub (7 , 8 , 9 );
61
61
expect (result ).toBe (undefined );
62
62
});
63
63
```
@@ -190,7 +190,8 @@ import { vi } from 'vitest';
190
190
import { when } from ' vitest-when' ;
191
191
192
192
const spy = vi .fn ();
193
- const stubWrapper = when (spy );
193
+
194
+ when (spy );
194
195
195
196
expect (spy ()).toBe (undefined );
196
197
```
@@ -201,7 +202,8 @@ Create a stub that matches a given set of arguments which you can configure with
201
202
202
203
``` ts
203
204
const spy = vi .fn ();
204
- const stub = when (spy ).calledWith (' hello' ).thenReturn (' world' );
205
+
206
+ when (spy ).calledWith (' hello' ).thenReturn (' world' );
205
207
206
208
expect (spy (' hello' )).toEqual (' world' );
207
209
```
@@ -220,10 +222,10 @@ expect(spy('anything')).toEqual('world');
220
222
If ` calledWith ` is used multiple times, the last configured stubbing will be used.
221
223
222
224
``` ts
223
- when (spy ).calledWith (" hello" ).thenReturn (" world" )
224
- expect (spy (" hello" )).toEqual (" world" )
225
- when (spy ).calledWith (" hello" ).thenReturn (" goodbye"
226
- expect (spy (" hello" )).toEqual (" goodbye" )
225
+ when (spy ).calledWith (' hello' ).thenReturn (' world' );
226
+ expect (spy (' hello' )).toEqual (' world' );
227
+ when (spy ).calledWith (' hello' ).thenReturn (' goodbye' );
228
+ expect (spy (' hello' )).toEqual (' goodbye' );
227
229
```
228
230
229
231
[ asymmetric matchers ] : https://vitest.dev/api/expect.html#expect-anything
0 commit comments