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

Commit 8d92103

Browse files
committed
Have SpyCall use any instead of unknown
1 parent 232da4a commit 8d92103

File tree

3 files changed

+26
-23
lines changed

3 files changed

+26
-23
lines changed

README.md

Lines changed: 20 additions & 20 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.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)
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/mock@0.11.0/mod.ts";
33+
import { spy, Spy } from "https://deno.land/x/mock@0.12.0/mod.ts";
3434
// 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";
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/mock@0.11.0/spy.ts";
43+
import { Spy, spy } from "https://deno.land/x/mock@0.12.0/spy.ts";
4444
// Import from GitHub
4545
import {
4646
Spy,
4747
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";
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.11.0.js";
72+
import { Spy, spy } from "./mock_0.12.0.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.11.0.mjs";
80+
import { Spy, spy } from "./mock_0.12.0.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.11.0.js";
99+
import { Spy, spy } from "./mock_0.12.0.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.11.0.js";
107+
import { spy, Spy } from "./mock_0.12.0.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/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
124124
more information.
125125

126126
### Spy
@@ -136,8 +136,8 @@ for any calls made to it.
136136

137137
```ts
138138
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";
141141

142142
function add(
143143
a: number,
@@ -164,7 +164,7 @@ normally, you can wrap it with a spy.
164164

165165
```ts
166166
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";
168168

169169
function filter<T>(values: T[], callback: (value: T) => boolean): any[] {
170170
return values.filter(callback);
@@ -196,7 +196,7 @@ spy error saying "already spying on function".
196196

197197
```ts
198198
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";
200200

201201
class Database {
202202
private queries: any;
@@ -285,7 +285,7 @@ calls made to it.
285285

286286
```ts
287287
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";
289289

290290
class Cat {
291291
action(name: string): any {
@@ -320,7 +320,7 @@ will return undefined to each call after the iterator is done.
320320

321321
```ts
322322
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";
324324

325325
class Database {
326326
query(query: string, params: any[]): any[][] {
@@ -394,7 +394,7 @@ instead of the original, you can create a stub with a replacement function.
394394

395395
```ts
396396
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";
398398

399399
class Database {
400400
query(query: string, params: any[]): any[][] {
@@ -470,8 +470,8 @@ controlled through the fake time instance.
470470

471471
```ts
472472
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";
475475

476476
function secondInterval(cb: () => void): void {
477477
setInterval(cb, 1000);

spy.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ export class SpyError extends Error {
1313
/** Call information recorded by a spy. */
1414
export interface SpyCall {
1515
/** Arguments passed to a function when called. */
16-
args: unknown[];
16+
// deno-lint-ignore no-explicit-any
17+
args: any[];
1718
/** The instance that a method was called on. */
18-
self?: unknown;
19+
// deno-lint-ignore no-explicit-any
20+
self?: any;
1921
/** The value that was returned by a function. */
2022
// deno-lint-ignore no-explicit-any
2123
returned?: any;

stub.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { AnySpyInternal, Spy, spy, SpyCall, SpyError } from "./spy.ts";
55
/** An instance method wrapper that overrides the original method and records all calls made to it. */
66
export interface Stub<T> extends Spy<T> {
77
/** The original value that was replaced with the stub. */
8-
original: unknown;
8+
// deno-lint-ignore no-explicit-any
9+
original: any;
910
}
1011
export type AnyStub<T> = Stub<T> | Stub<void>;
1112

0 commit comments

Comments
 (0)