@vnejs/compatibility.platform.metric-with-save 0.1.4 → 0.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vnejs/compatibility.platform.metric-with-save",
3
- "version": "0.1.4",
3
+ "version": "0.2.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "tsconfig.json"
19
19
  ],
20
20
  "scripts": {
21
- "test": "echo \"Error: no test specified\" && exit 1",
21
+ "test": "npx @vnejs/monorepo test",
22
22
  "build": "npx @vnejs/monorepo package",
23
23
  "publish:major:plugin": "npm run publish:major",
24
24
  "publish:minor:plugin": "npm run publish:minor",
@@ -30,12 +30,14 @@
30
30
  "author": "",
31
31
  "license": "ISC",
32
32
  "peerDependencies": {
33
- "@vnejs/module.core": "~0.1.0",
34
- "@vnejs/contracts.platform.metric": "~0.1.0",
35
- "@vnejs/contracts.save": "~0.1.0",
36
- "@vnejs/shared": "~0.1.0"
33
+ "@vnejs/module.core": "~0.2.0",
34
+ "@vnejs/contracts.platform.metric": "~0.2.0",
35
+ "@vnejs/contracts.save": "~0.2.0",
36
+ "@vnejs/shared": "~0.2.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@vnejs/configs.ts-common": "~0.1.0"
39
+ "@vnejs/configs.ts-common": "~0.2.0",
40
+ "@vnejs/configs.vitest": "~0.2.0",
41
+ "@vnejs/test-utils": "~0.2.0"
40
42
  }
41
43
  }
@@ -0,0 +1,30 @@
1
+ import { beforeEach, describe, expect, it, vi } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { CompatibilityMetricSave } from "../index.js";
6
+ import { createCompatibilityTestModule, METRIC_EVENTS, registerCompatibilityVne, SAVE_EVENTS } from "./setup.js";
7
+
8
+ describe("CompatibilityMetricSave", () => {
9
+ beforeEach(() => registerCompatibilityVne());
10
+
11
+ it("SAVE.CREATE forwards key to metric params", async () => {
12
+ const { observer } = createCompatibilityTestModule(CompatibilityMetricSave);
13
+ const params = spyEvent(observer, METRIC_EVENTS.PARAMS);
14
+
15
+ await observer.emit(SAVE_EVENTS.CREATE, { key: "slot-1" });
16
+
17
+ expect(params).toHaveBeenCalledOnce();
18
+ expect(params).toHaveBeenCalledWith({ VNE_SAVE: { key: "slot-1" } });
19
+ });
20
+
21
+ it("SAVE.LOAD forwards key to metric params", async () => {
22
+ const { observer } = createCompatibilityTestModule(CompatibilityMetricSave);
23
+ const params = spyEvent(observer, METRIC_EVENTS.PARAMS);
24
+
25
+ await observer.emit(SAVE_EVENTS.LOAD, { key: "slot-2" });
26
+
27
+ expect(params).toHaveBeenCalledOnce();
28
+ expect(params).toHaveBeenCalledWith({ VNE_LOAD: { key: "slot-2" } });
29
+ });
30
+ });
@@ -0,0 +1,16 @@
1
+ import { SUBSCRIBE_EVENTS as METRIC_EVENTS, PLUGIN_NAME as METRIC } from "@vnejs/contracts.platform.metric";
2
+ import { SUBSCRIBE_EVENTS as SAVE_EVENTS, PLUGIN_NAME as SAVE } from "@vnejs/contracts.save";
3
+ import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin } from "@vnejs/test-utils";
4
+
5
+ export const registerCompatibilityVne = () => {
6
+ registerCoreVne();
7
+ registerVnePlugin(SAVE, { events: SAVE_EVENTS });
8
+ registerVnePlugin(METRIC, { events: METRIC_EVENTS });
9
+ };
10
+
11
+ export const createCompatibilityTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
12
+ ModuleClass: T,
13
+ options: Parameters<typeof baseCreateTestModule>[1] = {},
14
+ ) => baseCreateTestModule(ModuleClass, options);
15
+
16
+ export { METRIC_EVENTS, SAVE_EVENTS };
package/tsconfig.json CHANGED
@@ -4,6 +4,12 @@
4
4
  "rootDir": "src",
5
5
  "outDir": "dist"
6
6
  },
7
- "include": ["src/**/*.ts"],
8
- "exclude": ["dist", "node_modules"]
7
+ "include": [
8
+ "src/**/*.ts"
9
+ ],
10
+ "exclude": [
11
+ "dist",
12
+ "node_modules",
13
+ "src/tests"
14
+ ]
9
15
  }