vona-mock 6.0.7 → 6.0.10

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016-present Vona
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1 +1 @@
1
- # egg-born-mock
1
+ # vona-mock
package/dist/index.d.ts CHANGED
@@ -1,16 +1,6 @@
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;
1
+ import type { IModuleInfo } from '@cabloy/module-info';
2
+ import type { VonaApplication } from 'vona-core';
3
+ export declare const app: VonaApplication;
12
4
  export declare function mockPath(path?: string): string;
13
5
  export declare function mockUrl(path?: string): string;
14
6
  export declare function mockModuleInfo(): IModuleInfo;
15
- export {};
16
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,50 +1,15 @@
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
- });
1
+ import { parseModuleInfo, ParseModuleNameLevelInit } from '@cabloy/module-info-pro';
2
+ import { useApp } from 'vona-core';
3
+ const ParseModuleNameLevel = ParseModuleNameLevelInit + 2;
4
+ export const app = useApp();
5
+ export function mockPath(path) {
6
+ const moduleInfo = parseModuleInfo(ParseModuleNameLevel);
7
+ return app.util.combineApiPath(path, moduleInfo.relativeName, false, true);
32
8
  }
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);
9
+ export function mockUrl(path) {
10
+ const moduleInfo = parseModuleInfo(ParseModuleNameLevel);
11
+ return app.util.combineApiPath(path, moduleInfo.relativeName, true, true);
41
12
  }
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);
13
+ export function mockModuleInfo() {
14
+ return parseModuleInfo(ParseModuleNameLevel);
46
15
  }
47
- function mockModuleInfo() {
48
- return (0, module_info_pro_1.parseModuleInfo)(ParseModuleNameLevel);
49
- }
50
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,42 +1,41 @@
1
1
  {
2
2
  "name": "vona-mock",
3
- "version": "6.0.7",
3
+ "type": "module",
4
+ "version": "6.0.10",
4
5
  "description": "vona mock",
5
6
  "publishConfig": {
6
7
  "access": "public"
7
8
  },
9
+ "author": "zhennann",
10
+ "keywords": [
11
+ "framework",
12
+ "cabloy"
13
+ ],
8
14
  "exports": {
9
15
  ".": {
10
16
  "types": [
11
- "./dist/index.d.ts",
12
- "./src/index.ts"
17
+ "./src/index.ts",
18
+ "./dist/index.d.ts"
13
19
  ],
14
- "import": "./dist/index.js",
15
- "require": "./dist/index.js",
16
- "default": "./src/index.ts"
20
+ "default": "./dist/index.js"
17
21
  },
18
22
  "./package.json": "./package.json"
19
23
  },
20
24
  "files": [
21
- "dist/**/*.js",
22
- "dist/**/*.d.ts"
25
+ "dist"
23
26
  ],
24
27
  "scripts": {
25
- "lint": "eslint ."
28
+ "lint": "eslint .",
29
+ "clean": "rimraf dist tsconfig.tsbuildinfo",
30
+ "tsc:publish": "npm run clean && tsc",
31
+ "prepublishOnly": "npm run tsc:publish",
32
+ "prepack": "clean-package",
33
+ "postpack": "clean-package restore"
26
34
  },
27
- "keywords": [
28
- "egg",
29
- "egg-born",
30
- "framework",
31
- "cabloy"
32
- ],
33
- "author": "zhennann",
34
35
  "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"
36
+ "@cabloy/module-info": "^1.3.11",
37
+ "@cabloy/module-info-pro": "^1.0.19",
38
+ "vona-core": "^5.0.10"
40
39
  },
41
- "gitHead": "2d40c063c115b230fdbc89f5a78b4412ebd0dfc9"
40
+ "gitHead": "df34902798a7fa93b09c494ef0ff86fe07598c83"
42
41
  }