-
Notifications
You must be signed in to change notification settings - Fork 31
/
index.test-d.ts
47 lines (40 loc) · 1.81 KB
/
index.test-d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { expectType } from 'tsd';
import { Application, Context } from 'egg';
import { MockApplication, MockAgent, ResultObject } from '.';
import { app, mock, mm } from './bootstrap';
expectType<MockApplication>(app);
expectType<Context>(app.currentContext);
expectType<Context | undefined>(app.ctxStorage.getStore());
expectType<MockApplication>(mock.app());
expectType<MockApplication>(mm.app());
expectType<MockAgent>(mm.app().mockAgent());
expectType<Application>(mm.app().mockHttpclient('url', 'post', { data: 'ok' }));
expectType<Application>(mm.app().mockHttpclient('url', 'post', 'data'));
expectType<Application>(mm.app().mockHttpclient('url', {
data: 'mock response',
repeats: 1,
}));
expectType<Application>(mm.app().mockHttpclient('url', () => {}));
expectType<Application>(mm.app().mockHttpclient('url', 'post', () => {}));
expectType<Application>(mm.app().mockHttpclient('url', 'get', {
data: 'mock response',
repeats: 1,
}));
expectType<void>(app.mockLog());
expectType<void>(app.mockLog('logger'));
expectType<void>(app.mockLog(app.logger));
expectType<void>(app.expectLog('foo string'));
expectType<void>(app.expectLog('foo string', 'coreLogger'));
expectType<void>(app.expectLog('foo string', app.coreLogger));
expectType<void>(app.expectLog(/foo string/));
expectType<void>(app.expectLog(/foo string/, 'coreLogger'));
expectType<void>(app.expectLog(/foo string/, app.coreLogger));
expectType<void>(mm.env('default'));
expectType<void>(mm.env('devserver'));
expectType<Promise<void>>(app.mockAgentRestore());
expectType<Promise<void>>(app.mockRestore());
expectType<Promise<void>>(app.mockContextScope(async () => {}));
expectType<Promise<void>>(app.mockContextScope(async (ctx) => {}));
expectType<Promise<void>>(app.backgroundTasksFinished());
const result: ResultObject = {};
expectType<number>(result.status!);