1
1
# Mock
2
2
3
- [ ![ release] ( https://img.shields.io/badge/release-0.12.1 -success )] ( https://github.com/udibo/mock/releases/tag/0.12.1 )
4
- [ ![ deno doc
] ( https://doc.deno.land/badge.svg )] ( https://doc.deno.land/https/deno.land/x/[email protected] .1 /mod.ts )
3
+ [ ![ release] ( https://img.shields.io/badge/release-0.12.2 -success )] ( https://github.com/udibo/mock/releases/tag/0.12.2 )
4
+ [ ![ deno doc
] ( https://doc.deno.land/badge.svg )] ( https://doc.deno.land/https/deno.land/x/[email protected] .2 /mod.ts )
5
5
[ ![ CI] ( https://github.com/udibo/mock/workflows/CI/badge.svg )] ( https://github.com/udibo/mock/actions?query=workflow%3ACI )
6
6
[ ![ codecov] ( https://codecov.io/gh/udibo/mock/branch/master/graph/badge.svg?token=TXORMSEHM7 )] ( https://codecov.io/gh/udibo/mock )
7
7
[ ![ license] ( https://img.shields.io/github/license/udibo/mock )] ( https://github.com/udibo/mock/blob/master/LICENSE )
@@ -30,22 +30,22 @@ imported directly from GitHub using raw content URLs.
30
30
31
31
``` ts
32
32
// Import from Deno's third party module registry
33
- import {
spy ,
Spy }
from " https://deno.land/x/[email protected] .1 /mod.ts" ;
33
+ import {
spy ,
Spy }
from " https://deno.land/x/[email protected] .2 /mod.ts" ;
34
34
// Import from GitHub
35
- import { spy , Spy } " https://raw.githubusercontent.com/udibo/mock/0.12.1 /mod.ts" ;
35
+ import { spy , Spy } " https://raw.githubusercontent.com/udibo/mock/0.12.2 /mod.ts" ;
36
36
` ` `
37
37
38
38
If you do not need all of the sub-modules, you can choose to just import the
39
39
sub-modules you need.
40
40
41
41
` ` ` ts
42
42
// Import from Deno's third party module registry
43
- import {
Spy ,
spy }
from " https://deno.land/x/[email protected] .1 /spy.ts" ;
43
+ import {
Spy ,
spy }
from " https://deno.land/x/[email protected] .2 /spy.ts" ;
44
44
// Import from GitHub
45
45
import {
46
46
Spy ,
47
47
spy ,
48
- } from " https://raw.githubusercontent.com/udibo/mock/0.12.1 /spy.ts" ;
48
+ } from " https://raw.githubusercontent.com/udibo/mock/0.12.2 /spy.ts" ;
49
49
```
50
50
51
51
#### Sub-modules
@@ -69,15 +69,15 @@ If a Node.js package has the type "module" specified in its package.json file,
69
69
the JavaScript bundle can be imported as a ` .js ` file.
70
70
71
71
``` js
72
- import { Spy , spy } from " ./mock_0.12.1 .js" ;
72
+ import { Spy , spy } from " ./mock_0.12.2 .js" ;
73
73
```
74
74
75
75
The default type for Node.js packages is "commonjs". To import the bundle into a
76
76
commonjs package, the file extension of the JavaScript bundle must be changed
77
77
from ` .js ` to ` .mjs ` .
78
78
79
79
``` js
80
- import { Spy , spy } from " ./mock_0.12.1 .mjs" ;
80
+ import { Spy , spy } from " ./mock_0.12.2 .mjs" ;
81
81
```
82
82
83
83
See [ Node.js Documentation] ( https://nodejs.org/api/esm.html ) for more
@@ -96,15 +96,15 @@ modules must have the type attribute set to "module".
96
96
97
97
``` js
98
98
// main.js
99
- import { Spy , spy } from " ./mock_0.12.1 .js" ;
99
+ import { Spy , spy } from " ./mock_0.12.2 .js" ;
100
100
```
101
101
102
102
You can also embed a module script directly into an HTML file by placing the
103
103
JavaScript code within the body of the script tag.
104
104
105
105
``` html
106
106
<script type =" module" >
107
- import { spy , Spy } from " ./mock_0.12.1 .js" ;
107
+ import { spy , Spy } from " ./mock_0.12.2 .js" ;
108
108
</script >
109
109
```
110
110
@@ -120,7 +120,7 @@ a try block then restore the function in a finally block to ensure the original
120
120
instance method is restored before continuing to other tests. The same applies
121
121
when using fake time.
122
122
123
- See
[ deno docs
] ( https://doc.deno.land/https/deno.land/x/[email protected] .1 /mod.ts ) for
123
+ See
[ deno docs
] ( https://doc.deno.land/https/deno.land/x/[email protected] .2 /mod.ts ) for
124
124
more information.
125
125
126
126
### Spy
@@ -135,12 +135,12 @@ anything, you can create an empty spy. An empty spy will just return undefined
135
135
for any calls made to it.
136
136
137
137
``` ts
138
- import { assertEquals } from " https://deno.land/std@0.115.1 /testing/asserts.ts" ;
138
+ import { assertEquals } from " https://deno.land/std@0.120.0 /testing/asserts.ts" ;
139
139
import {
140
140
assertSpyCall ,
141
141
Spy ,
142
142
spy ,
143
- }
from " https://deno.land/x/[email protected] .1 /mod.ts" ;
143
+ }
from " https://deno.land/x/[email protected] .2 /mod.ts" ;
144
144
145
145
function add(
146
146
a : number ,
@@ -166,13 +166,13 @@ If you have a function that takes a callback that needs to still behave
166
166
normally, you can wrap it with a spy.
167
167
168
168
``` ts
169
- import { assertEquals } from " https://deno.land/std@0.115.1 /testing/asserts.ts" ;
169
+ import { assertEquals } from " https://deno.land/std@0.120.0 /testing/asserts.ts" ;
170
170
import {
171
171
assertSpyCall ,
172
172
assertSpyCalls ,
173
173
Spy ,
174
174
spy ,
175
- }
from " https://deno.land/x/[email protected] .1 /mod.ts" ;
175
+ }
from " https://deno.land/x/[email protected] .2 /mod.ts" ;
176
176
177
177
function filter<T >(values : T [], callback : (value : T ) => boolean ): any [] {
178
178
return values .filter (callback );
@@ -202,13 +202,13 @@ method. If it is not restored and you attempt to wrap it again, it will throw a
202
202
spy error saying "already spying on function".
203
203
204
204
``` ts
205
- import { assertEquals } from " https://deno.land/std@0.115.1 /testing/asserts.ts" ;
205
+ import { assertEquals } from " https://deno.land/std@0.120.0 /testing/asserts.ts" ;
206
206
import {
207
207
assertSpyCall ,
208
208
assertSpyCalls ,
209
209
Spy ,
210
210
spy ,
211
- }
from " https://deno.land/x/[email protected] .1 /mod.ts" ;
211
+ }
from " https://deno.land/x/[email protected] .2 /mod.ts" ;
212
212
213
213
class Database {
214
214
// deno-lint-ignore no-explicit-any
@@ -298,8 +298,8 @@ you can create an empty stub. An empty stub will just return undefined for any
298
298
calls made to it.
299
299
300
300
``` ts
301
- import { assertEquals } from " https://deno.land/std@0.115.1 /testing/asserts.ts" ;
302
- import {
Stub ,
stub }
from " https://deno.land/x/[email protected] .1 /stub.ts" ;
301
+ import { assertEquals } from " https://deno.land/std@0.120.0 /testing/asserts.ts" ;
302
+ import {
Stub ,
stub }
from " https://deno.land/x/[email protected] .2 /stub.ts" ;
303
303
304
304
class Cat {
305
305
action(name : string ): any {
@@ -336,14 +336,14 @@ considered complete if called after all values have been returned. The callback
336
336
will return undefined to each call after the iterator is done.
337
337
338
338
``` ts
339
- import { assertEquals } from " https://deno.land/std@0.115.1 /testing/asserts.ts" ;
339
+ import { assertEquals } from " https://deno.land/std@0.120.0 /testing/asserts.ts" ;
340
340
import {
341
341
assertSpyCallAsync ,
342
342
assertSpyCalls ,
343
343
resolvesNext ,
344
344
Stub ,
345
345
stub ,
346
- }
from " https://deno.land/x/[email protected] .1 /mod.ts" ;
346
+ }
from " https://deno.land/x/[email protected] .2 /mod.ts" ;
347
347
348
348
class Database {
349
349
query(_query : string , _params : unknown []): Promise <unknown [][]> {
@@ -420,7 +420,7 @@ Overrides the real Date object and timer functions with fake ones that can be
420
420
controlled through the fake time instance.
421
421
422
422
``` ts
423
- import {
FakeTime ,
Spy ,
spy }
from " https://deno.land/x/[email protected] .1 /mod.ts" ;
423
+ import {
FakeTime ,
Spy ,
spy }
from " https://deno.land/x/[email protected] .2 /mod.ts" ;
424
424
425
425
function secondInterval(cb : () => void ): void {
426
426
setInterval (cb , 1000 );
0 commit comments