@eggjs/mock 6.1.0-beta.6 → 6.1.0-beta.8

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.
@@ -1,10 +1,10 @@
1
1
  import { MockHttpClientMethod, MockResultFunction, MockResultOptions } from "../../lib/mock_httpclient.js";
2
- import { EggCore } from "@eggjs/core";
2
+ import { Agent } from "egg";
3
3
  import { mock, restore } from "mm";
4
4
  import * as urllib0 from "urllib";
5
5
 
6
6
  //#region src/app/extend/agent.d.ts
7
- declare abstract class AgentUnittest extends EggCore {
7
+ declare abstract class AgentUnittest extends Agent {
8
8
  [key: string]: any;
9
9
  _mockHttpClient: MockHttpClientMethod;
10
10
  /**
@@ -1,10 +1,10 @@
1
1
  import { getMockAgent, restoreMockAgent } from "../../lib/mock_agent.js";
2
2
  import { createMockHttpClient } from "../../lib/mock_httpclient.js";
3
- import { EggCore } from "@eggjs/core";
3
+ import { Agent } from "egg";
4
4
  import { mock, restore } from "mm";
5
5
 
6
6
  //#region src/app/extend/agent.ts
7
- var AgentUnittest = class extends EggCore {
7
+ var AgentUnittest = class extends Agent {
8
8
  _mockHttpClient;
9
9
  /**
10
10
  * mock httpclient
@@ -1,12 +1,11 @@
1
1
  import { MockHttpClientMethod, MockResultFunction, MockResultOptions } from "../../lib/mock_httpclient.js";
2
2
  import { EggTestRequest } from "../../lib/supertest.js";
3
3
  import { MockOptions } from "../../lib/types.js";
4
- import { Context, EggCore, EggCoreOptions } from "@eggjs/core";
4
+ import { Application, Context } from "egg";
5
5
  import { mock } from "mm";
6
6
  import { IncomingMessage } from "node:http";
7
7
  import { Logger } from "egg-logger";
8
- import * as urllib1 from "urllib";
9
- import { HttpClient } from "urllib";
8
+ import { MockAgent } from "urllib";
10
9
 
11
10
  //#region src/app/extend/application.d.ts
12
11
  interface MockContextOptions {
@@ -23,14 +22,14 @@ interface MockContextData {
23
22
  headers?: Record<string, string | string[]>;
24
23
  [key: string]: any;
25
24
  }
26
- interface MockContext extends EggContext, Context {
25
+ interface MockContext extends Context {
27
26
  service: any;
28
27
  }
29
- declare abstract class ApplicationUnittest extends EggCore {
28
+ declare abstract class ApplicationUnittest extends Application {
30
29
  [key: string]: any;
31
- options: MockOptions & EggCoreOptions;
30
+ options: MockOptions & Application['options'];
32
31
  _mockHttpClient?: MockHttpClientMethod;
33
- httpclient: HttpClient;
32
+ agent: NonNullable<Application['agent']>;
34
33
  /**
35
34
  * mock Context
36
35
  * @function App#mockContext
@@ -117,7 +116,7 @@ declare abstract class ApplicationUnittest extends EggCore {
117
116
  * get mock httpclient agent
118
117
  * @function App#mockHttpclientAgent
119
118
  */
120
- mockAgent(): urllib1.MockAgent<urllib1.MockAgent.Options>;
119
+ mockAgent(): MockAgent;
121
120
  mockAgentRestore(): Promise<void>;
122
121
  /**
123
122
  * @see mm#restore
@@ -1,7 +1,7 @@
1
1
  import { request } from "../../lib/supertest.js";
2
2
  import { getMockAgent, restoreMockAgent } from "../../lib/mock_agent.js";
3
3
  import { createMockHttpClient } from "../../lib/mock_httpclient.js";
4
- import { EggCore } from "@eggjs/core";
4
+ import { Application } from "egg";
5
5
  import assert from "node:assert";
6
6
  import { mock, restore } from "mm";
7
7
  import { debuglog } from "node:util";
@@ -16,7 +16,7 @@ const debug = debuglog("egg/mock/app/extend/application");
16
16
  const ORIGIN_TYPES = Symbol("@eggjs/mock originTypes");
17
17
  const BACKGROUND_TASKS = Symbol("Application#backgroundTasks");
18
18
  const REUSED_CTX = Symbol("Context#reusedInSuite");
19
- var ApplicationUnittest = class extends EggCore {
19
+ var ApplicationUnittest = class extends Application {
20
20
  _mockHttpClient;
21
21
  /**
22
22
  * mock Context
@@ -1,4 +1,4 @@
1
- import { Context, Next } from "@eggjs/core";
1
+ import { Context, Next } from "egg";
2
2
 
3
3
  //#region src/app/middleware/cluster_app_mock.d.ts
4
4
  declare const _default: () => (ctx: Context, next: Next) => Promise<void>;
@@ -1,4 +1,4 @@
1
- import { Context } from "@eggjs/core";
1
+ import { Context } from "egg";
2
2
  import { debuglog } from "node:util";
3
3
 
4
4
  //#region src/app/middleware/cluster_app_mock.ts
package/dist/app.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { EggCore, ILifecycleBoot } from "@eggjs/core";
1
+ import { Application, ILifecycleBoot } from "egg";
2
2
 
3
3
  //#region src/app.d.ts
4
4
  declare class Boot implements ILifecycleBoot {
5
5
  #private;
6
- constructor(app: EggCore);
6
+ constructor(app: Application);
7
7
  configWillLoad(): void;
8
8
  }
9
9
  //#endregion
package/dist/app.js CHANGED
@@ -1,4 +1,4 @@
1
- import { EggCore } from "@eggjs/core";
1
+ import { Application } from "egg";
2
2
 
3
3
  //#region src/app.ts
4
4
  var Boot = class {
@@ -2,7 +2,6 @@ import { utils } from "@eggjs/core";
2
2
 
3
3
  //#region src/lib/context.ts
4
4
  const context = { runInBackground(scope) {
5
- /* istanbul ignore next */
6
5
  const taskName = scope._name || scope.name || utils.getCalleeFromStack(true);
7
6
  if (taskName) scope._name = taskName;
8
7
  const promise = this._runInBackground(scope);
@@ -3,7 +3,7 @@ import { HttpClient, MockAgent } from "urllib";
3
3
  //#region src/lib/mock_agent.d.ts
4
4
  declare function getMockAgent(app?: {
5
5
  httpClient?: HttpClient;
6
- }): MockAgent<MockAgent.Options>;
6
+ }): MockAgent;
7
7
  declare function restoreMockAgent(): Promise<void>;
8
8
  //#endregion
9
9
  export { getMockAgent, restoreMockAgent };
@@ -1,6 +1,6 @@
1
1
  import { MockApplicationOptions, MockOptions } from "../types.js";
2
2
  import { APP_INIT } from "./util.js";
3
- import { EggCore } from "@eggjs/core";
3
+ import { Agent } from "egg";
4
4
  import { Base } from "sdk-base";
5
5
 
6
6
  //#region src/lib/parallel/agent.d.ts
@@ -9,7 +9,7 @@ declare class MockAgent extends Base {
9
9
  options: MockApplicationOptions;
10
10
  baseDir: string;
11
11
  [APP_INIT]: boolean;
12
- _instance: EggCore;
12
+ _instance: Agent;
13
13
  constructor(options: MockApplicationOptions);
14
14
  _init(): Promise<void>;
15
15
  on(...args: any[]): this;
@@ -1,6 +1,6 @@
1
1
  import { MockApplicationOptions, MockOptions } from "../types.js";
2
2
  import { APP_INIT } from "./util.js";
3
- import { EggCore } from "@eggjs/core";
3
+ import { Application } from "egg";
4
4
  import { Base } from "sdk-base";
5
5
 
6
6
  //#region src/lib/parallel/app.d.ts
@@ -9,7 +9,7 @@ declare class MockParallelApplication extends Base {
9
9
  options: MockApplicationOptions;
10
10
  baseDir: string;
11
11
  [APP_INIT]: boolean;
12
- _instance: EggCore;
12
+ _instance: Application;
13
13
  constructor(options: MockApplicationOptions);
14
14
  _init(): Promise<void>;
15
15
  on(...args: any[]): this;
@@ -4,6 +4,7 @@ import { formatOptions } from "../format_options.js";
4
4
  import { context } from "../context.js";
5
5
  import { setCustomLoader } from "../mock_custom_loader.js";
6
6
  import { APP_INIT, proxyApp } from "./util.js";
7
+ import { Application } from "egg";
7
8
  import { debuglog } from "node:util";
8
9
  import { importModule } from "@eggjs/utils";
9
10
  import { Base } from "sdk-base";
@@ -29,8 +30,8 @@ var MockParallelApplication = class extends Base {
29
30
  if (!this.options.clusterPort) this.options.clusterPort = parseInt(process.env.CLUSTER_PORT);
30
31
  if (!this.options.clusterPort) throw new Error("cannot get env.CLUSTER_PORT, parallel run fail");
31
32
  debug("get clusterPort %s", this.options.clusterPort);
32
- const { Application } = await importModule(this.options.framework);
33
- const app = this._instance = new Application({ ...this.options });
33
+ const { Application: Application$1 } = await importModule(this.options.framework);
34
+ const app = this._instance = new Application$1({ ...this.options });
34
35
  Object.assign(app.context, context);
35
36
  setCustomLoader(app);
36
37
  debug("app instantiate");
@@ -332,7 +332,8 @@ var require_conversions = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
332
332
  const v = hsv[2] / 100;
333
333
  const vmin = Math.max(v, .01);
334
334
  let sl;
335
- let l = (2 - s) * v;
335
+ let l;
336
+ l = (2 - s) * v;
336
337
  const lmin = (2 - s) * vmin;
337
338
  sl = s * vmin;
338
339
  sl /= lmin <= 1 ? lmin : 2 - lmin;
@@ -486,7 +487,8 @@ var require_conversions = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm
486
487
  const l = lab[0];
487
488
  const a = lab[1];
488
489
  const b = lab[2];
489
- let h = Math.atan2(b, a) * 360 / 2 / Math.PI;
490
+ let h;
491
+ h = Math.atan2(b, a) * 360 / 2 / Math.PI;
490
492
  if (h < 0) h += 360;
491
493
  const c = Math.sqrt(a * a + b * b);
492
494
  return [
@@ -1 +1 @@
1
- export { };
1
+ import "egg";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eggjs/mock",
3
- "version": "6.1.0-beta.6",
3
+ "version": "6.1.0-beta.8",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -76,10 +76,13 @@
76
76
  "sdk-base": "^5.0.1",
77
77
  "urllib": "^4.6.11",
78
78
  "utility": "^2.5.0",
79
- "@eggjs/core": "6.6.0-beta.6",
80
- "@eggjs/supertest": "8.3.0-beta.6",
81
- "@eggjs/extend2": "4.1.0-beta.6",
82
- "@eggjs/utils": "4.5.0-beta.6"
79
+ "@eggjs/core": "6.6.0-beta.8",
80
+ "@eggjs/supertest": "8.3.0-beta.8",
81
+ "@eggjs/utils": "4.5.0-beta.8",
82
+ "@eggjs/extend2": "4.1.0-beta.8"
83
+ },
84
+ "peerDependencies": {
85
+ "egg": "4.1.0-beta.8"
83
86
  },
84
87
  "devDependencies": {
85
88
  "@eggjs/tegg": "^3.2.2",
@@ -94,8 +97,7 @@
94
97
  "tsd": "^0.33.0",
95
98
  "tsdown": "^0.15.0",
96
99
  "typescript": "5.9.2",
97
- "@eggjs/tsconfig": "3.1.0-beta.6",
98
- "egg": "4.1.0-beta.6"
100
+ "egg": "4.1.0-beta.8"
99
101
  },
100
102
  "scripts": {
101
103
  "build": "tsdown",