@vnejs/plugins.text.meet 0.1.1 → 0.1.2

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.meet",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
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,34 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { SUBSCRIBE_EVENTS as TEXT_EVENTS } from "@vnejs/contracts.text";
4
+ import { SUBSCRIBE_EVENTS as SCENARIO_EVENTS } from "@vnejs/contracts.core.scenario";
5
+ import { spyEvent } from "@vnejs/test-utils";
6
+
7
+ import { TextMeet } from "../modules/meet.js";
8
+ import { createTextMeetTestModule, registerTextMeetPluginVne, SUBSCRIBE_EVENTS } from "./setup.js";
9
+
10
+ describe("TextMeet", () => {
11
+ beforeEach(() => {
12
+ registerTextMeetPluginVne();
13
+ });
14
+
15
+ it("MEET increments speaker meet counter", async () => {
16
+ const { observer } = createTextMeetTestModule(TextMeet);
17
+ const update = spyEvent(observer, TEXT_EVENTS.SPEAKER_INFO_UPDATE);
18
+
19
+ await observer.emit(SUBSCRIBE_EVENTS.MEET, { speaker: "hero", value: 2 });
20
+
21
+ expect(update).toHaveBeenCalledExactlyOnceWith({ speaker: "hero", info: { meet: 3 } });
22
+ });
23
+
24
+ it("onLineExec emits MEET and advances scenario", async () => {
25
+ const { module, observer } = createTextMeetTestModule(TextMeet, { subscribe: false });
26
+ const meet = spyEvent(observer, SUBSCRIBE_EVENTS.MEET);
27
+ const next = spyEvent(observer, SCENARIO_EVENTS.NEXT);
28
+
29
+ await (module as TextMeet).onLineExec({ line: "hero 3" });
30
+
31
+ expect(meet).toHaveBeenCalledExactlyOnceWith({ speaker: "hero", value: "3" });
32
+ expect(next).toHaveBeenCalledOnce();
33
+ });
34
+ });
@@ -0,0 +1,20 @@
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.meet";
3
+ import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin } from "@vnejs/test-utils";
4
+
5
+ export const registerTextMeetPluginVne = () => {
6
+ registerCoreVne();
7
+ registerVnePlugin(TEXT, { events: TEXT_EVENTS });
8
+ registerVnePlugin(PLUGIN_NAME, { events: SUBSCRIBE_EVENTS });
9
+ };
10
+
11
+ export const createTextMeetTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
12
+ ModuleClass: T,
13
+ options: Parameters<typeof baseCreateTestModule>[1] = {},
14
+ ) =>
15
+ baseCreateTestModule(ModuleClass, {
16
+ state: { "text.speaker": { speaker: "", args: {}, speakersInfo: { hero: { meet: 1 } } }, ...(options.state ?? {}) },
17
+ ...options,
18
+ });
19
+
20
+ export { SUBSCRIBE_EVENTS, TEXT_EVENTS, PLUGIN_NAME };
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
  }