@vnejs/compatibility.rpg.skills-with-scales 0.1.9 → 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.rpg.skills-with-scales",
3
- "version": "0.1.9",
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.rpg.skills": "~0.1.0",
35
- "@vnejs/contracts.scales": "~0.1.0",
36
- "@vnejs/shared": "~0.1.0"
33
+ "@vnejs/module.core": "~0.2.0",
34
+ "@vnejs/contracts.rpg.skills": "~0.2.0",
35
+ "@vnejs/contracts.scales": "~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,19 @@
1
+ import "@vnejs/contracts.scales.health";
2
+ import { PARAMS as ENTITIES_PARAMS, PLUGIN_NAME as ENTITIES } from "@vnejs/contracts.entities";
3
+ import { SUBSCRIBE_EVENTS as SCALES_EVENTS, PLUGIN_NAME as SCALES } from "@vnejs/contracts.scales";
4
+ import { SUBSCRIBE_EVENTS as SKILLS_EVENTS, PLUGIN_NAME as SKILLS } from "@vnejs/contracts.rpg.skills";
5
+ import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin } from "@vnejs/test-utils";
6
+
7
+ export const registerCompatibilityVne = () => {
8
+ registerCoreVne();
9
+ registerVnePlugin(ENTITIES, { params: ENTITIES_PARAMS });
10
+ registerVnePlugin(SCALES, { events: SCALES_EVENTS });
11
+ registerVnePlugin(SKILLS, { events: SKILLS_EVENTS });
12
+ };
13
+
14
+ export const createCompatibilityTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
15
+ ModuleClass: T,
16
+ options: Parameters<typeof baseCreateTestModule>[1] = {},
17
+ ) => baseCreateTestModule(ModuleClass, options);
18
+
19
+ export { SCALES_EVENTS, SKILLS_EVENTS };
@@ -0,0 +1,30 @@
1
+ import { beforeEach, describe, expect, it, vi } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { CompatibilitySkillsScales } from "../index.js";
6
+ import { createCompatibilityTestModule, registerCompatibilityVne, SCALES_EVENTS, SKILLS_EVENTS } from "./setup.js";
7
+
8
+ describe("CompatibilitySkillsScales", () => {
9
+ beforeEach(() => registerCompatibilityVne());
10
+
11
+ it("SKILLS.EMIT_START emits negative SCALES.CHANGE shifts", async () => {
12
+ const { observer } = createCompatibilityTestModule(CompatibilitySkillsScales);
13
+ const change = spyEvent(observer, SCALES_EVENTS.CHANGE);
14
+
15
+ await observer.emit(SKILLS_EVENTS.EMIT_START, { entityType: "unit", entityId: "hero", scales: { health: 5 } });
16
+
17
+ expect(change).toHaveBeenCalledOnce();
18
+ expect(change).toHaveBeenCalledWith({ key: "unit:hero:health", shift: -5 });
19
+ });
20
+
21
+ it("SKILLS.CHECK forwards value to SCALES.CHECK", async () => {
22
+ const { observer } = createCompatibilityTestModule(CompatibilitySkillsScales);
23
+ const check = spyEvent(observer, SCALES_EVENTS.CHECK);
24
+
25
+ await observer.emit(SKILLS_EVENTS.CHECK, { entityType: "unit", entityId: "hero", scales: { health: 10 } });
26
+
27
+ expect(check).toHaveBeenCalledOnce();
28
+ expect(check).toHaveBeenCalledWith({ key: "unit:hero:health", value: 10 });
29
+ });
30
+ });
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
  }