File tree 6 files changed +9
-43
lines changed
6 files changed +9
-43
lines changed Original file line number Diff line number Diff line change @@ -27,12 +27,6 @@ cmd.mock();
27
27
assert (Deno .Command !== Original );
28
28
```
29
29
30
- Return a disposable:
31
-
32
- ``` typescript
33
- assert (Symbol .dispose in cmd .mock ());
34
- ```
35
-
36
30
#### ` use `
37
31
38
32
Replace Deno.Command inside the callback:
@@ -143,12 +137,6 @@ import * as fs from "jsr:@chiezo/amber/fs";
143
137
144
138
#### ` mock `
145
139
146
- Return a disposable:
147
-
148
- ``` typescript
149
- assert (Symbol .dispose in fs .mock ());
150
- ```
151
-
152
140
Replace file system functions as side effects:
153
141
154
142
``` typescript
Original file line number Diff line number Diff line change @@ -2,13 +2,11 @@ import type { ConstructorSpy } from "@std/testing/mock";
2
2
import * as std from "@std/testing/mock" ;
3
3
import { tryFinally } from "./internal.ts" ;
4
4
5
- export interface Spy < Command extends string | URL >
6
- extends
7
- Disposable ,
8
- ConstructorSpy <
9
- Deno . Command ,
10
- [ command : Command , options ?: Deno . CommandOptions ]
11
- > { }
5
+ export interface Spy < Command extends string | URL > extends
6
+ ConstructorSpy <
7
+ Deno . Command ,
8
+ [ command : Command , options ?: Deno . CommandOptions ]
9
+ > { }
12
10
13
11
export interface Stub < Command extends string | URL > extends Spy < Command > {
14
12
fake : typeof Deno . Command ;
@@ -95,11 +93,8 @@ export function dispose() {
95
93
spies . clear ( ) ;
96
94
}
97
95
98
- export function mock ( ) : Disposable {
96
+ export function mock ( ) {
99
97
Deno . Command = CommandProxy ;
100
- return {
101
- [ Symbol . dispose ] : dispose ,
102
- } ;
103
98
}
104
99
105
100
export function use < T > ( fn : ( ) => T ) : T {
Original file line number Diff line number Diff line change @@ -14,10 +14,6 @@ describe("mock", () => {
14
14
cmd . mock ( ) ;
15
15
assert ( Deno . Command !== Original ) ;
16
16
} ) ;
17
-
18
- it ( "should return a disposable" , ( ) => {
19
- assert ( Symbol . dispose in cmd . mock ( ) ) ;
20
- } ) ;
21
17
} ) ;
22
18
23
19
describe ( "use" , ( ) => {
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ type FsSpy = {
105
105
} ;
106
106
107
107
/** A record of spies for Deno APIs related to file system operations. */
108
- export interface FileSystemSpy extends Disposable , FsSpy {
108
+ export interface FileSystemSpy extends FsSpy {
109
109
}
110
110
111
111
/** A record of stubs for Deno APIs related to file system operations. */
@@ -209,10 +209,6 @@ export function stub(
209
209
fs ,
210
210
( fn , name ) => fake [ name ] ? std . spy ( fake , name ) : fn ,
211
211
) ,
212
- [ Symbol . dispose ] : ( ) => {
213
- spies . delete ( path ) ;
214
- fs . removeSync ( temp , { recursive : true } ) ;
215
- } ,
216
212
} as FileSystemStub ;
217
213
218
214
spies . set ( path , stub ) ;
@@ -225,16 +221,11 @@ export function spy(
225
221
return stub ( path , createFs ( ) ) ;
226
222
}
227
223
228
- export function mock ( ) : Disposable {
224
+ export function mock ( ) {
229
225
if ( spies . size === 0 ) {
230
226
stub ( Deno . cwd ( ) ) ;
231
227
}
232
228
FsFnNames . forEach ( ( name ) => mockFsFn ( name ) ) ;
233
- return {
234
- [ Symbol . dispose ] ( ) {
235
- dispose ( ) ;
236
- } ,
237
- } ;
238
229
}
239
230
240
231
function mockFsFn < T extends FsFnName > ( name : T ) {
Original file line number Diff line number Diff line change @@ -8,10 +8,6 @@ describe("mock", () => {
8
8
9
9
afterEach ( ( ) => fs . dispose ( ) ) ;
10
10
11
- it ( "should return a disposable" , ( ) => {
12
- assert ( Symbol . dispose in fs . mock ( ) ) ;
13
- } ) ;
14
-
15
11
it ( "should replace file system functions as side effects" , ( ) => {
16
12
fs . mock ( ) ;
17
13
assert ( Deno . readTextFile !== original . readTextFile ) ;
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { tryFinally } from "./internal.ts";
2
2
3
3
export interface MockModule {
4
4
dispose ( ) : void ;
5
- mock ( ) : Disposable ;
5
+ mock ( ) : void ;
6
6
restore ( ) : void ;
7
7
use < T > ( fn : ( ) => T ) : T ;
8
8
}
You can’t perform that action at this time.
0 commit comments