1
1
# Mock
2
2
3
- [ ![ release] ( https://img.shields.io/badge/release-0.11 .0-success )] ( https://github.com/udibo/mock/releases/tag/0.11 .0 )
4
- [ ![ deno doc] ( https://doc.deno.land/badge.svg )] ( https://doc.deno.land/https/deno.land/x/mock@0.11 .0/mod.ts )
3
+ [ ![ release] ( https://img.shields.io/badge/release-0.12 .0-success )] ( https://github.com/udibo/mock/releases/tag/0.12 .0 )
4
+ [ ![ deno doc] ( https://doc.deno.land/badge.svg )] ( https://doc.deno.land/https/deno.land/x/mock@0.12 .0/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/mock@0.11 .0/mod.ts" ;
33
+ import { spy , Spy } from " https://deno.land/x/mock@0.12 .0/mod.ts" ;
34
34
// Import from GitHub
35
- import { spy , Spy } " https://raw.githubusercontent.com/udibo/mock/0.11 .0/mod.ts" ;
35
+ import { spy , Spy } " https://raw.githubusercontent.com/udibo/mock/0.12 .0/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/mock@0.11 .0/spy.ts" ;
43
+ import { Spy , spy } from " https://deno.land/x/mock@0.12 .0/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.11 .0/spy.ts" ;
48
+ } from " https://raw.githubusercontent.com/udibo/mock/0.12 .0/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.11 .0.js" ;
72
+ import { Spy , spy } from " ./mock_0.12 .0.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.11 .0.mjs" ;
80
+ import { Spy , spy } from " ./mock_0.12 .0.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.11 .0.js" ;
99
+ import { Spy , spy } from " ./mock_0.12 .0.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.11 .0.js" ;
107
+ import { spy , Spy } from " ./mock_0.12 .0.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/mock@0.11 .0/mod.ts ) for
123
+ See [ deno docs] ( https://doc.deno.land/https/deno.land/x/mock@0.12 .0/mod.ts ) for
124
124
more information.
125
125
126
126
### Spy
@@ -136,8 +136,8 @@ for any calls made to it.
136
136
137
137
``` ts
138
138
import {
assertEquals }
from " https://deno.land/[email protected] /testing/asserts.ts" ;
139
- import { assertSpyCall } from " https://deno.land/x/mock@0.11 .0/asserts.ts" ;
140
- import { Spy , spy } from " https://deno.land/x/mock@0.11 .0/spy.ts" ;
139
+ import { assertSpyCall } from " https://deno.land/x/mock@0.12 .0/asserts.ts" ;
140
+ import { Spy , spy } from " https://deno.land/x/mock@0.12 .0/spy.ts" ;
141
141
142
142
function add(
143
143
a : number ,
@@ -164,7 +164,7 @@ normally, you can wrap it with a spy.
164
164
165
165
``` ts
166
166
import {
assertEquals }
from " https://deno.land/[email protected] /testing/asserts.ts" ;
167
- import { Spy , spy } from " https://deno.land/x/mock@0.11 .0/spy.ts" ;
167
+ import { Spy , spy } from " https://deno.land/x/mock@0.12 .0/spy.ts" ;
168
168
169
169
function filter<T >(values : T [], callback : (value : T ) => boolean ): any [] {
170
170
return values .filter (callback );
@@ -196,7 +196,7 @@ spy error saying "already spying on function".
196
196
197
197
``` ts
198
198
import {
assertEquals }
from " https://deno.land/[email protected] /testing/asserts.ts" ;
199
- import { Spy , spy } from " https://deno.land/x/mock@0.11 .0/spy.ts" ;
199
+ import { Spy , spy } from " https://deno.land/x/mock@0.12 .0/spy.ts" ;
200
200
201
201
class Database {
202
202
private queries: any ;
@@ -285,7 +285,7 @@ calls made to it.
285
285
286
286
``` ts
287
287
import {
assertEquals }
from " https://deno.land/[email protected] /testing/asserts.ts" ;
288
- import { Stub , stub } from " https://deno.land/x/mock@0.11 .0/stub.ts" ;
288
+ import { Stub , stub } from " https://deno.land/x/mock@0.12 .0/stub.ts" ;
289
289
290
290
class Cat {
291
291
action(name : string ): any {
@@ -320,7 +320,7 @@ will return undefined to each call after the iterator is done.
320
320
321
321
``` ts
322
322
import {
assertEquals }
from " https://deno.land/[email protected] /testing/asserts.ts" ;
323
- import { Stub , stub } from " https://deno.land/x/mock@0.11 .0/stub.ts" ;
323
+ import { Stub , stub } from " https://deno.land/x/mock@0.12 .0/stub.ts" ;
324
324
325
325
class Database {
326
326
query(query : string , params : any []): any [][] {
@@ -394,7 +394,7 @@ instead of the original, you can create a stub with a replacement function.
394
394
395
395
``` ts
396
396
import {
assertEquals }
from " https://deno.land/[email protected] /testing/asserts.ts" ;
397
- import { Stub , stub } from " https://deno.land/x/mock@0.11 .0/stub.ts" ;
397
+ import { Stub , stub } from " https://deno.land/x/mock@0.12 .0/stub.ts" ;
398
398
399
399
class Database {
400
400
query(query : string , params : any []): any [][] {
@@ -470,8 +470,8 @@ controlled through the fake time instance.
470
470
471
471
``` ts
472
472
import {
assertEquals }
from " https://deno.land/[email protected] /testing/asserts.ts" ;
473
- import { Spy , spy } from " https://deno.land/x/mock@0.11 .0/spy.ts" ;
474
- import { FakeTime } from " https://deno.land/x/mock@0.11 .0/time.ts" ;
473
+ import { Spy , spy } from " https://deno.land/x/mock@0.12 .0/spy.ts" ;
474
+ import { FakeTime } from " https://deno.land/x/mock@0.12 .0/time.ts" ;
475
475
476
476
function secondInterval(cb : () => void ): void {
477
477
setInterval (cb , 1000 );
0 commit comments