Total Complexity | 8 |
Complexity/F | 1 |
Lines of Code | 43 |
Function Count | 8 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import fse from 'fs-extra'; |
||
2 | import API from './entry'; |
||
3 | import { tmpFolder } from './constants'; |
||
4 | import { mockAPI, unMockAPI, startMockApp, stopMockApp } from './mock'; |
||
5 | |||
6 | export * from './utils'; |
||
7 | export * from './constants'; |
||
8 | |||
9 | export default class Test { |
||
10 | createAPI(url = 'http://mock/', opts = {}) { |
||
11 | return new API(url, opts); |
||
12 | } |
||
13 | |||
14 | async setTmpFolder() { |
||
15 | await fse.ensureDir(tmpFolder); |
||
16 | } |
||
17 | |||
18 | async cleanTmpFolder() { |
||
19 | await fse.remove(tmpFolder); |
||
20 | } |
||
21 | |||
22 | mockAPI() { |
||
23 | mockAPI(); |
||
24 | } |
||
25 | |||
26 | unMockAPI() { |
||
27 | unMockAPI(); |
||
28 | } |
||
29 | |||
30 | async startMockApp() { |
||
31 | this._server = await startMockApp(); |
||
32 | } |
||
33 | |||
34 | get mockAppUrl() { |
||
35 | const { port } = this._server.address(); |
||
36 | |||
37 | return `http://localhost:${port}`; |
||
38 | } |
||
39 | |||
40 | async stopMockApp() { |
||
41 | await stopMockApp(this._server); |
||
42 | } |
||
43 | } |
||
44 | |||
45 |