vona-mock 6.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # egg-born-mock
@@ -0,0 +1,16 @@
1
+ import { VonaApplication, VonaContext } from 'vona';
2
+ import Assert from 'assert';
3
+ import { IModuleInfo } from '@cabloy/module-info';
4
+ import { BaseMockApplication } from 'egg-mock';
5
+ type TypeMockCabloyApplication<T, C> = BaseMockApplication<T, C> & VonaApplication;
6
+ export interface MockCabloyApplication extends TypeMockCabloyApplication<VonaApplication, VonaContext> {
7
+ }
8
+ export declare const assert: typeof Assert;
9
+ export declare const app: MockCabloyApplication;
10
+ export declare const mock: any;
11
+ export declare const mm: any;
12
+ export declare function mockPath(path?: string): string;
13
+ export declare function mockUrl(path?: string): string;
14
+ export declare function mockModuleInfo(): IModuleInfo;
15
+ export {};
16
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.mm = exports.mock = exports.app = exports.assert = void 0;
7
+ exports.mockPath = mockPath;
8
+ exports.mockUrl = mockUrl;
9
+ exports.mockModuleInfo = mockModuleInfo;
10
+ const bootstrap_js_1 = __importDefault(require("egg-mock/bootstrap.js"));
11
+ const vona_1 = require("vona");
12
+ const assert_1 = __importDefault(require("assert"));
13
+ const module_info_pro_1 = require("@cabloy/module-info-pro");
14
+ const ParseModuleNameLevel = module_info_pro_1.ParseModuleNameLevelInit + 2;
15
+ let Bundle = global.__egg_born_mock;
16
+ if (!Bundle) {
17
+ Bundle = global.__egg_born_mock = bootstrap_js_1.default;
18
+ before(async function () {
19
+ const app = (0, vona_1.Cast)(Bundle.app);
20
+ // wait ready
21
+ await Bundle.app.ready();
22
+ // session
23
+ Bundle.app.mockSession({});
24
+ // wait app ready
25
+ await app.meta.checkAppReady();
26
+ // restore
27
+ Bundle.mock.restore();
28
+ });
29
+ after(async function () {
30
+ await Bundle.app.close();
31
+ });
32
+ }
33
+ exports.assert = assert_1.default;
34
+ exports.app = (0, vona_1.Cast)(Bundle.app);
35
+ exports.mock = Bundle.mock;
36
+ exports.mm = Bundle.mm;
37
+ function mockPath(path) {
38
+ const moduleInfo = (0, module_info_pro_1.parseModuleInfo)(ParseModuleNameLevel);
39
+ const app = (0, vona_1.Cast)(Bundle.app);
40
+ return app.meta.util.combineFetchPath(moduleInfo, path, false, true);
41
+ }
42
+ function mockUrl(path) {
43
+ const moduleInfo = (0, module_info_pro_1.parseModuleInfo)(ParseModuleNameLevel);
44
+ const app = (0, vona_1.Cast)(Bundle.app);
45
+ return app.meta.util.combineFetchPath(moduleInfo, path, true, true);
46
+ }
47
+ function mockModuleInfo() {
48
+ return (0, module_info_pro_1.parseModuleInfo)(ParseModuleNameLevel);
49
+ }
50
+ //# sourceMappingURL=index.js.map
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "vona-mock",
3
+ "version": "6.0.7",
4
+ "description": "vona mock",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "exports": {
9
+ ".": {
10
+ "types": [
11
+ "./dist/index.d.ts",
12
+ "./src/index.ts"
13
+ ],
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.js",
16
+ "default": "./src/index.ts"
17
+ },
18
+ "./package.json": "./package.json"
19
+ },
20
+ "files": [
21
+ "dist/**/*.js",
22
+ "dist/**/*.d.ts"
23
+ ],
24
+ "scripts": {
25
+ "lint": "eslint ."
26
+ },
27
+ "keywords": [
28
+ "egg",
29
+ "egg-born",
30
+ "framework",
31
+ "cabloy"
32
+ ],
33
+ "author": "zhennann",
34
+ "dependencies": {
35
+ "@cabloy/module-info": "^1.1.8",
36
+ "@cabloy/module-info-pro": "^1.0.16",
37
+ "@types/mocha": "^10.0.1",
38
+ "assert": "^2.1.0",
39
+ "egg-mock": "^5.10.9"
40
+ },
41
+ "gitHead": "2d40c063c115b230fdbc89f5a78b4412ebd0dfc9"
42
+ }