Skip to content
This repository was archived by the owner on Apr 18, 2022. It is now read-only.

Commit 5bdbbf6

Browse files
committed
Fix time type error with dom lib compiler options
1 parent 9769c74 commit 5bdbbf6

File tree

3 files changed

+31
-30
lines changed

3 files changed

+31
-30
lines changed

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Mock
22

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)
55
[![CI](https://github.com/udibo/mock/workflows/CI/badge.svg)](https://github.com/udibo/mock/actions?query=workflow%3ACI)
66
[![codecov](https://codecov.io/gh/udibo/mock/branch/master/graph/badge.svg?token=TXORMSEHM7)](https://codecov.io/gh/udibo/mock)
77
[![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.
3030

3131
```ts
3232
// 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";
3434
// 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";
3636
```
3737
3838
If you do not need all of the sub-modules, you can choose to just import the
3939
sub-modules you need.
4040
4141
```ts
4242
// 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";
4444
// Import from GitHub
4545
import {
4646
Spy,
4747
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";
4949
```
5050

5151
#### Sub-modules
@@ -69,15 +69,15 @@ If a Node.js package has the type "module" specified in its package.json file,
6969
the JavaScript bundle can be imported as a `.js` file.
7070

7171
```js
72-
import { Spy, spy } from "./mock_0.12.1.js";
72+
import { Spy, spy } from "./mock_0.12.2.js";
7373
```
7474

7575
The default type for Node.js packages is "commonjs". To import the bundle into a
7676
commonjs package, the file extension of the JavaScript bundle must be changed
7777
from `.js` to `.mjs`.
7878

7979
```js
80-
import { Spy, spy } from "./mock_0.12.1.mjs";
80+
import { Spy, spy } from "./mock_0.12.2.mjs";
8181
```
8282

8383
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".
9696

9797
```js
9898
// main.js
99-
import { Spy, spy } from "./mock_0.12.1.js";
99+
import { Spy, spy } from "./mock_0.12.2.js";
100100
```
101101

102102
You can also embed a module script directly into an HTML file by placing the
103103
JavaScript code within the body of the script tag.
104104

105105
```html
106106
<script type="module">
107-
import { spy, Spy } from "./mock_0.12.1.js";
107+
import { spy, Spy } from "./mock_0.12.2.js";
108108
</script>
109109
```
110110

@@ -120,7 +120,7 @@ a try block then restore the function in a finally block to ensure the original
120120
instance method is restored before continuing to other tests. The same applies
121121
when using fake time.
122122

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
124124
more information.
125125

126126
### Spy
@@ -135,12 +135,12 @@ anything, you can create an empty spy. An empty spy will just return undefined
135135
for any calls made to it.
136136

137137
```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";
139139
import {
140140
assertSpyCall,
141141
Spy,
142142
spy,
143-
} from "https://deno.land/x/[email protected].1/mod.ts";
143+
} from "https://deno.land/x/[email protected].2/mod.ts";
144144

145145
function add(
146146
a: number,
@@ -166,13 +166,13 @@ If you have a function that takes a callback that needs to still behave
166166
normally, you can wrap it with a spy.
167167

168168
```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";
170170
import {
171171
assertSpyCall,
172172
assertSpyCalls,
173173
Spy,
174174
spy,
175-
} from "https://deno.land/x/[email protected].1/mod.ts";
175+
} from "https://deno.land/x/[email protected].2/mod.ts";
176176

177177
function filter<T>(values: T[], callback: (value: T) => boolean): any[] {
178178
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
202202
spy error saying "already spying on function".
203203

204204
```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";
206206
import {
207207
assertSpyCall,
208208
assertSpyCalls,
209209
Spy,
210210
spy,
211-
} from "https://deno.land/x/[email protected].1/mod.ts";
211+
} from "https://deno.land/x/[email protected].2/mod.ts";
212212

213213
class Database {
214214
// 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
298298
calls made to it.
299299

300300
```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";
303303

304304
class Cat {
305305
action(name: string): any {
@@ -336,14 +336,14 @@ considered complete if called after all values have been returned. The callback
336336
will return undefined to each call after the iterator is done.
337337

338338
```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";
340340
import {
341341
assertSpyCallAsync,
342342
assertSpyCalls,
343343
resolvesNext,
344344
Stub,
345345
stub,
346-
} from "https://deno.land/x/[email protected].1/mod.ts";
346+
} from "https://deno.land/x/[email protected].2/mod.ts";
347347

348348
class Database {
349349
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
420420
controlled through the fake time instance.
421421

422422
```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";
424424

425425
function secondInterval(cb: () => void): void {
426426
setInterval(cb, 1000);

deps.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export { delay } from "https://deno.land/std@0.115.1/async/delay.ts";
2-
export type { DelayOptions } from "https://deno.land/std@0.115.1/async/delay.ts";
1+
export { delay } from "https://deno.land/std@0.120.0/async/delay.ts";
2+
export type { DelayOptions } from "https://deno.land/std@0.120.0/async/delay.ts";
33

44
export {
55
assert,
@@ -10,7 +10,7 @@ export {
1010
assertRejects,
1111
assertStrictEquals,
1212
assertThrows,
13-
} from "https://deno.land/std@0.115.1/testing/asserts.ts";
13+
} from "https://deno.land/std@0.120.0/testing/asserts.ts";
1414

1515
export { RBTree } from "https://deno.land/x/[email protected]/trees/rb_tree.ts";
1616
export { ascend } from "https://deno.land/x/[email protected]/comparators.ts";

time.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function* timerId() {
142142
interface Timer {
143143
id: number;
144144
// deno-lint-ignore no-explicit-any
145-
callback: (...args: any[]) => unknown;
145+
callback: (...args: any[]) => void;
146146
delay: number;
147147
args: unknown[];
148148
due: number;
@@ -234,7 +234,7 @@ export class FakeTime {
234234

235235
static setTimeout(
236236
// deno-lint-ignore no-explicit-any
237-
callback: (...args: any[]) => unknown,
237+
callback: (...args: any[]) => void,
238238
delay = 0,
239239
// deno-lint-ignore no-explicit-any
240240
...args: any[]
@@ -268,9 +268,10 @@ export class FakeTime {
268268

269269
private overrideGlobals(): void {
270270
globalThis.Date = FakeDate;
271-
globalThis.setTimeout = FakeTime.setTimeout;
271+
globalThis.setTimeout = FakeTime.setTimeout as typeof NativeTime.setTimeout;
272272
globalThis.clearTimeout = FakeTime.clearTimeout;
273-
globalThis.setInterval = FakeTime.setInterval;
273+
globalThis.setInterval = FakeTime
274+
.setInterval as typeof NativeTime.setInterval;
274275
globalThis.clearInterval = FakeTime.clearInterval;
275276
}
276277

@@ -284,7 +285,7 @@ export class FakeTime {
284285

285286
private setTimer(
286287
// deno-lint-ignore no-explicit-any
287-
callback: (...args: any[]) => unknown,
288+
callback: (...args: any[]) => void,
288289
delay = 0,
289290
args: unknown[],
290291
repeat = false,

0 commit comments

Comments
 (0)