@vnejs/plugins.text.wall 0.1.3 → 0.1.4

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/plugins.text.wall",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
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",
@@ -39,6 +39,9 @@
39
39
  "@vnejs/shared": "~0.1.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@vnejs/configs.ts-common": "~0.1.0"
42
+ "@vnejs/configs.ts-common": "~0.1.0",
43
+ "@vnejs/configs.vitest": "~0.1.0",
44
+ "@vnejs/test-utils": "~0.1.0",
45
+ "@vnejs/contracts.text": "~0.1.0"
43
46
  }
44
47
  }
@@ -0,0 +1,29 @@
1
+ import { CONSTANTS as TEXT_CONST, PLUGIN_NAME as TEXT, SUBSCRIBE_EVENTS as TEXT_EVENTS } from "@vnejs/contracts.text";
2
+ import { PLUGIN_NAME, SUBSCRIBE_EVENTS } from "@vnejs/contracts.text.wall";
3
+ import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin, stubSilentEvent } from "@vnejs/test-utils";
4
+
5
+ export const registerTextWallPluginVne = () => {
6
+ registerCoreVne();
7
+ registerVnePlugin(TEXT, { events: TEXT_EVENTS });
8
+ registerVnePlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS });
9
+ };
10
+
11
+ export const createTextWallTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
12
+ ModuleClass: T,
13
+ options: Parameters<typeof baseCreateTestModule>[1] = {},
14
+ ) => {
15
+ const result = baseCreateTestModule(ModuleClass, {
16
+ state: {
17
+ text: { uid: "1", texts: [{ text: "line", args: {} }], tokens: [], speaker: "hero" },
18
+ "text.speaker": { speakers: { hero: {} }, speaker: "hero" },
19
+ ...(options.state ?? {}),
20
+ },
21
+ ...options,
22
+ });
23
+
24
+ stubSilentEvent(result.observer, SUBSCRIBE_EVENTS.CHANGED);
25
+
26
+ return result;
27
+ };
28
+
29
+ export { SUBSCRIBE_EVENTS, PLUGIN_NAME };
@@ -0,0 +1,36 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { SUBSCRIBE_EVENTS as SCENARIO_EVENTS } from "@vnejs/contracts.core.scenario";
4
+ import { spyEvent } from "@vnejs/test-utils";
5
+
6
+ import { TextWall } from "../modules/wall.js";
7
+ import { createTextWallTestModule, registerTextWallPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
8
+
9
+ describe("TextWall", () => {
10
+ beforeEach(() => {
11
+ registerTextWallPluginVne();
12
+ });
13
+
14
+ it("start command enables wall capture", async () => {
15
+ const { module, observer } = createTextWallTestModule(TextWall, { subscribe: false });
16
+ const changed = spyEvent(observer, SUBSCRIBE_EVENTS.CHANGED);
17
+ const next = spyEvent(observer, SCENARIO_EVENTS.NEXT);
18
+
19
+ await (module as TextWall).onLineExec({ line: "start" });
20
+
21
+ expect((module as TextWall).state.isStarted).toBe(true);
22
+ expect(changed).toHaveBeenCalledOnce();
23
+ expect(next).toHaveBeenCalledOnce();
24
+ });
25
+
26
+ it("clear command resets wall", async () => {
27
+ const { module, observer } = createTextWallTestModule(TextWall, { subscribe: false });
28
+
29
+ (module as TextWall).setState({ wall: [{ texts: [], tokens: [], uid: "1", speaker: "hero", speakerInfo: {} }], isStarted: true, shouldSkip: false });
30
+
31
+ await (module as TextWall).onLineExec({ line: "clear" });
32
+
33
+ expect((module as TextWall).state.wall).toEqual([]);
34
+ expect((module as TextWall).state.shouldSkip).toBe(true);
35
+ });
36
+ });
package/tsconfig.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "outDir": "dist"
6
6
  },
7
7
  "include": ["src/**/*.ts"],
8
- "exclude": ["dist", "node_modules"]
8
+ "exclude": ["dist", "node_modules", "src/tests"]
9
9
  }