1
- import { MethodToStub } from "../src/MethodToStub" ;
2
- import { instance , mock , when } from "../src/ts-mockito" ;
3
- import { Bar } from "./utils/Bar" ;
4
- import { ThenableClass } from "./utils/Thenable" ;
5
- import { EventEmitter } from "events" ;
1
+ import { MethodToStub } from "../src/MethodToStub" ;
2
+ import { instance , mock , when } from "../src/ts-mockito" ;
3
+ import { Bar } from "./utils/Bar" ;
4
+ import { ThenableClass } from "./utils/Thenable" ;
5
+ import { EventEmitter } from "events" ;
6
6
7
7
describe ( "mocking" , ( ) => {
8
8
describe ( "mocking abstract class" , ( ) => {
@@ -228,19 +228,26 @@ describe("mocking", () => {
228
228
} ) ;
229
229
} ) ;
230
230
231
- describe ( "mocking native class" , ( ) => {
231
+ describe ( "mocking native class" , ( ) => {
232
232
it ( "should mock" , ( ) => {
233
233
const mocked = mock ( TestEmitter ) ;
234
234
expect ( mocked ) . toBeDefined ( ) ;
235
235
} ) ;
236
236
} ) ;
237
237
238
- describe ( "mocking anon class" , ( ) => {
238
+ describe ( "mocking anon class" , ( ) => {
239
239
it ( "should mock" , ( ) => {
240
240
const mocked = mock ( TestAnonClass ) ;
241
241
expect ( mocked ) . toBeDefined ( ) ;
242
242
} ) ;
243
243
} ) ;
244
+
245
+ describe ( "mocking async class" , ( ) => {
246
+ it ( "should mock" , ( ) => {
247
+ const mocked = mock ( AsyncClass ) ;
248
+ expect ( mocked ) . toBeDefined ( ) ;
249
+ } ) ;
250
+ } ) ;
244
251
} ) ;
245
252
246
253
abstract class SampleAbstractClass {
@@ -307,8 +314,21 @@ class SampleGeneric<T> {
307
314
}
308
315
}
309
316
310
- class TestEmitter extends EventEmitter { }
317
+ class TestEmitter extends EventEmitter {
318
+ }
311
319
312
320
const TestAnonClass = class {
313
321
private readonly foo = 'abc' ;
314
- } ;
322
+ } ;
323
+
324
+ export class AsyncClass {
325
+ public asyncValueArrowFn = async ( ) => 'value' ;
326
+
327
+ public asyncValueFn = async function hello ( ) {
328
+ return 'value' ;
329
+ } ;
330
+
331
+ public async returnAsyncValue ( ) : Promise < number > {
332
+ return 0 ;
333
+ }
334
+ }
0 commit comments