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

Commit f70edcc

Browse files
committed
Upgrade Deno to 1.4.0
1 parent 85d0507 commit f70edcc

File tree

13 files changed

+72
-48
lines changed

13 files changed

+72
-48
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ jobs:
2222
- name: Install deno
2323
uses: denolib/setup-deno@master
2424
with:
25-
deno-version: 1.3.3
25+
deno-version: 1.4.0
2626
- name: Check formatting
2727
if: matrix.config.kind == 'lint'
2828
run: |
2929
deno fmt --check
3030
deno lint --unstable
3131
- name: Test
3232
if: matrix.config.kind == 'test'
33-
run: deno test
33+
run: deno test --coverage --unstable
3434
- name: Release info
3535
if: |
3636
matrix.config.kind == 'test' &&

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"deno.enable": true,
3+
"deno.unstable": true,
4+
"deno.lint": true,
35
"[typescript]": {
46
"editor.defaultFormatter": "denoland.vscode-deno"
57
}

README.md

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

3-
[![version](https://img.shields.io/badge/release-v0.5.1-success)](https://github.com/udibo/mock/tree/v0.5.1)
4-
[![deno doc](https://img.shields.io/badge/deno-doc-success?logo=deno)](https://doc.deno.land/https/deno.land/x/mock@v0.5.1/mod.ts)
5-
[![deno version](https://img.shields.io/badge/deno-v1.3.3-success?logo=deno)](https://github.com/denoland/deno/tree/v1.3.3)
3+
[![version](https://img.shields.io/badge/release-v0.6.0-success)](https://github.com/udibo/mock/tree/v0.6.0)
4+
[![deno doc](https://img.shields.io/badge/deno-doc-success?logo=deno)](https://doc.deno.land/https/deno.land/x/mock@v0.6.0/mod.ts)
5+
[![deno version](https://img.shields.io/badge/deno-v1.4.0-success?logo=deno)](https://github.com/denoland/deno/tree/v1.4.0)
66
[![CI](https://github.com/udibo/mock/workflows/CI/badge.svg)](https://github.com/udibo/mock/actions?query=workflow%3ACI)
77
[![license](https://img.shields.io/github/license/udibo/mock)](https://github.com/udibo/mock/blob/master/LICENSE)
88

@@ -26,18 +26,18 @@ but can also be imported directly from GitHub using raw content URLs.
2626

2727
```ts
2828
// Import from Deno's third party module registry
29-
import { spy, Spy } from "https://deno.land/x/mock@v0.5.1/mod.ts";
29+
import { spy, Spy } from "https://deno.land/x/mock@v0.6.0/mod.ts";
3030
// Import from GitHub
31-
import { spy, Spy } "https://raw.githubusercontent.com/udibo/mock/v0.5.1/mod.ts";
31+
import { spy, Spy } "https://raw.githubusercontent.com/udibo/mock/v0.6.0/mod.ts";
3232
```
3333
3434
If you do not need all of the sub-modules, you can choose to just import the sub-modules you need.
3535
3636
```ts
3737
// Import from Deno's third party module registry
38-
import { spy, Spy } from "https://deno.land/x/mock@v0.5.1/spy.ts";
38+
import { spy, Spy } from "https://deno.land/x/mock@v0.6.0/spy.ts";
3939
// Import from GitHub
40-
import { spy, Spy } from "https://raw.githubusercontent.com/udibo/mock/v0.5.1/spy.ts";
40+
import { spy, Spy } from "https://raw.githubusercontent.com/udibo/mock/v0.6.0/spy.ts";
4141
```
4242

4343
#### Sub-modules
@@ -57,14 +57,14 @@ Node.js fully supports ES Modules.
5757
If a Node.js package has the type "module" specified in its package.json file, the JavaScript bundle can be imported as a `.js` file.
5858

5959
```js
60-
import { spy, Spy } from "./mock_v0.5.1.js";
60+
import { spy, Spy } from "./mock_v0.6.0.js";
6161
```
6262

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

6666
```js
67-
import { spy, Spy } from "./mock_v0.5.1.mjs";
67+
import { spy, Spy } from "./mock_v0.6.0.mjs";
6868
```
6969

7070
See [Node.js Documentation](https://nodejs.org/api/esm.html) for more information.
@@ -82,15 +82,15 @@ Script tags for ES modules must have the type attribute set to "module".
8282

8383
```js
8484
// main.js
85-
import { spy, Spy } from "./mock_v0.5.1.js";
85+
import { spy, Spy } from "./mock_v0.6.0.js";
8686
```
8787

8888
You can also embed a module script directly into an HTML file by placing the JavaScript code
8989
within the body of the script tag.
9090

9191
```html
9292
<script type="module">
93-
import { spy, Spy } from "./mock_v0.5.1.js";
93+
import { spy, Spy } from "./mock_v0.6.0.js";
9494
</script>
9595
```
9696

@@ -100,7 +100,7 @@ See [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/
100100

101101
Below are some examples of how to use Spys, Stubs, and FakeTime in tests. When spying/stubing instance methods, you should wrap the calls and expectations with a try block then restore the function in a finally block to ensure the original instance method is restored before continuing to other tests. The same applies when using fake time.
102102

103-
See [deno docs](https://doc.deno.land/https/deno.land/x/mock@v0.5.1/mod.ts) for more information.
103+
See [deno docs](https://doc.deno.land/https/deno.land/x/mock@v0.6.0/mod.ts) for more information.
104104

105105
### Spy
106106

@@ -110,7 +110,7 @@ If you have a function that takes a callback but you don't need it to do anythin
110110

111111
```ts
112112
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
113-
import { spy, Spy } from "https://deno.land/x/mock@v0.5.1/spy.ts";
113+
import { spy, Spy } from "https://deno.land/x/mock@v0.6.0/spy.ts";
114114

115115
function add(
116116
a: number,
@@ -138,7 +138,7 @@ If you have a function that takes a callback that needs to still behave normally
138138

139139
```ts
140140
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
141-
import { spy, Spy } from "https://deno.land/x/mock@v0.5.1/spy.ts";
141+
import { spy, Spy } from "https://deno.land/x/mock@v0.6.0/spy.ts";
142142

143143
function filter<T>(values: T[], callback: (value: T) => boolean): any[] {
144144
return values.filter(callback);
@@ -166,7 +166,7 @@ If you have an instance method that needs to still behave normally, you can wrap
166166

167167
```ts
168168
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
169-
import { spy, Spy } from "https://deno.land/x/mock@v0.5.1/spy.ts";
169+
import { spy, Spy } from "https://deno.land/x/mock@v0.6.0/spy.ts";
170170

171171
class Database {
172172
private queries: any;
@@ -250,7 +250,7 @@ If you have an instance method but you don't need it to do or return anything, y
250250

251251
```ts
252252
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
253-
import { stub, Stub } from "https://deno.land/x/mock@v0.5.1/stub.ts";
253+
import { stub, Stub } from "https://deno.land/x/mock@v0.6.0/stub.ts";
254254

255255
class Cat {
256256
action(name: string): any {
@@ -284,7 +284,7 @@ If you have an instance method but need it to return specific values for each ca
284284

285285
```ts
286286
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
287-
import { stub, Stub } from "https://deno.land/x/mock@v0.5.1/stub.ts";
287+
import { stub, Stub } from "https://deno.land/x/mock@v0.6.0/stub.ts";
288288

289289
class Database {
290290
query(query: string, params: any[]): any[][] {
@@ -356,7 +356,7 @@ If you have an instance method but need it to call a replacement function instea
356356

357357
```ts
358358
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
359-
import { stub, Stub } from "https://deno.land/x/mock@v0.5.1/stub.ts";
359+
import { stub, Stub } from "https://deno.land/x/mock@v0.6.0/stub.ts";
360360

361361
class Database {
362362
query(query: string, params: any[]): any[][] {
@@ -432,8 +432,8 @@ controlled through the fake time instance.
432432

433433
```ts
434434
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
435-
import { spy, Spy } from "https://deno.land/x/mock@v0.5.1/spy.ts";
436-
import { FakeTime } from "https://deno.land/x/mock@v0.5.1/time.ts";
435+
import { spy, Spy } from "https://deno.land/x/mock@v0.6.0/spy.ts";
436+
import { FakeTime } from "https://deno.land/x/mock@v0.6.0/time.ts";
437437

438438
function secondInterval(cb: () => void): void {
439439
setInterval(cb, 1000);

callbacks.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ export function returnsThis<T>(): (...args: any[]) => ThisType<T> {
1111
/** Creates a function that returns one of its arguments. */
1212
// deno-lint-ignore no-explicit-any
1313
export function returnsArg(idx: number): (...args: any[]) => any {
14-
return function () {
15-
return arguments[idx];
14+
// deno-lint-ignore no-explicit-any
15+
return function (...args: any[]) {
16+
return args[idx];
1617
};
1718
}
1819

@@ -22,8 +23,9 @@ export function returnsArgs(
2223
end?: number,
2324
// deno-lint-ignore no-explicit-any
2425
): (...args: any[]) => any {
25-
return function () {
26-
return Array.prototype.slice.call(arguments, start, end);
26+
// deno-lint-ignore no-explicit-any
27+
return function (...args: any[]) {
28+
return Array.prototype.slice.call(args, start, end);
2729
};
2830
}
2931

deps/std/async/delay.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { delay } from "https://deno.land/std@0.67.0/async/delay.ts";
1+
export { delay } from "https://deno.land/std@0.69.0/async/delay.ts";

deps/std/testing/asserts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ export {
66
assertThrows,
77
assertThrowsAsync,
88
AssertionError,
9-
} from "https://deno.land/std@0.67.0/testing/asserts.ts";
9+
} from "https://deno.land/std@0.69.0/testing/asserts.ts";

deps/udibo/collections/comparators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { ascend } from "https://deno.land/x/collections@v0.5.2/comparators.ts";
1+
export { ascend } from "https://deno.land/x/collections@v0.6.0/comparators.ts";
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { RBTree } from "https://deno.land/x/collections@v0.5.2/trees/rb_tree.ts";
1+
export { RBTree } from "https://deno.land/x/collections@v0.6.0/trees/rb_tree.ts";

deps/udibo/collections/vector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { Vector } from "https://deno.land/x/collections@v0.5.2/vector.ts";
1+
export { Vector } from "https://deno.land/x/collections@v0.6.0/vector.ts";

spy.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,22 @@ function spy<T>(
9191
): AnySpy<T> {
9292
const calls: SpyCall[] = [];
9393
// deno-lint-ignore no-explicit-any
94-
const result: AnySpy<T> = function (this: T | void): any {
94+
const result: AnySpy<T> = function (this: T | void, ...args: any[]): any {
9595
if (spyInternal.restored) {
9696
throw new SpyError("instance method already restored");
9797
}
98-
const call: SpyCall = { args: [...arguments] };
98+
const call: SpyCall = { args };
9999
// deno-lint-ignore no-explicit-any
100100
let returned: any;
101101
if (this) call.self = this;
102102
try {
103103
if (typeof spyInternal.func === "function") {
104-
returned = spyInternal.func.apply(this, Array.from(arguments));
104+
returned = spyInternal.func.apply(this, Array.from(args));
105105
} else {
106106
// deno-lint-ignore no-explicit-any
107107
const func: (...args: any[]) => any = spyInternal.get?.call(undefined);
108108
if (typeof func === "function") {
109-
func.apply(this, Array.from(arguments));
109+
func.apply(this, Array.from(args));
110110
} else {
111111
throw new SpyError("not a function");
112112
}
@@ -173,8 +173,9 @@ function spy<T>(
173173
get: function () {
174174
return spyInternal.get?.call(this);
175175
},
176-
set: function () {
177-
spyInternal.set?.apply(this, Array.from(arguments));
176+
// deno-lint-ignore no-explicit-any
177+
set: function (...args: any[]) {
178+
spyInternal.set?.apply(this, Array.from(args));
178179
},
179180
});
180181
} else if (typeof objOrFunc === "function") {

0 commit comments

Comments
 (0)