@vnejs/compatibility.text-with-scenario.autoread 0.1.12 → 0.1.13

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.text-with-scenario.autoread",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
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",
@@ -36,6 +36,8 @@
36
36
  "@vnejs/shared": "~0.1.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@vnejs/configs.ts-common": "~0.1.0"
39
+ "@vnejs/configs.ts-common": "~0.1.0",
40
+ "@vnejs/configs.vitest": "~0.1.0",
41
+ "@vnejs/test-utils": "~0.1.0"
40
42
  }
41
43
  }
@@ -0,0 +1,32 @@
1
+ import { beforeEach, describe, expect, it } from "vitest";
2
+
3
+ import { spyEvent } from "@vnejs/test-utils";
4
+
5
+ import { CompatibilityTextAutoread } from "../index.js";
6
+ import { AUTOREAD_EVENTS, createCompatibilityTestModule, registerCompatibilityVne, TEXT_CONST, TEXT_EVENTS } from "./setup.js";
7
+
8
+ describe("CompatibilityTextAutoread", () => {
9
+ beforeEach(() => {
10
+ registerCompatibilityVne();
11
+ });
12
+
13
+ it("TEXT.EMIT emits AUTOREAD.PUSH with text source", async () => {
14
+ const { observer } = createCompatibilityTestModule(CompatibilityTextAutoread);
15
+ const push = spyEvent(observer, AUTOREAD_EVENTS.PUSH);
16
+
17
+ await observer.emit(TEXT_EVENTS.EMIT);
18
+
19
+ expect(push).toHaveBeenCalledOnce();
20
+ expect(push).toHaveBeenCalledWith({ source: TEXT_CONST.SOURCE });
21
+ });
22
+
23
+ it("TEXT.EMIT_END emits AUTOREAD.POP with text source", async () => {
24
+ const { observer } = createCompatibilityTestModule(CompatibilityTextAutoread);
25
+ const pop = spyEvent(observer, AUTOREAD_EVENTS.POP);
26
+
27
+ await observer.emit(TEXT_EVENTS.EMIT_END);
28
+
29
+ expect(pop).toHaveBeenCalledOnce();
30
+ expect(pop).toHaveBeenCalledWith({ source: TEXT_CONST.SOURCE });
31
+ });
32
+ });
@@ -0,0 +1,16 @@
1
+ import { PARAMS as AUTOREAD_PARAMS, PLUGIN_NAME as AUTOREAD, SETTINGS_KEYS as AUTOREAD_SETTINGS, SUBSCRIBE_EVENTS as AUTOREAD_EVENTS } from "@vnejs/contracts.scenario.autoread";
2
+ import { CONSTANTS as TEXT_CONST, PARAMS as TEXT_PARAMS, PLUGIN_NAME as TEXT, SETTINGS_KEYS as TEXT_SETTINGS, SUBSCRIBE_EVENTS as TEXT_EVENTS } from "@vnejs/contracts.text";
3
+ import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin } from "@vnejs/test-utils";
4
+
5
+ export const registerCompatibilityVne = () => {
6
+ registerCoreVne();
7
+ registerVnePlugin(TEXT, { constants: TEXT_CONST, events: TEXT_EVENTS, params: TEXT_PARAMS, settings: TEXT_SETTINGS });
8
+ registerVnePlugin(AUTOREAD, { events: AUTOREAD_EVENTS, params: AUTOREAD_PARAMS, settings: AUTOREAD_SETTINGS });
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 { AUTOREAD_EVENTS, TEXT_CONST, TEXT_EVENTS };
package/tsconfig.json CHANGED
@@ -2,5 +2,5 @@
2
2
  "extends": "@vnejs/configs.ts-common/tsconfig.json",
3
3
  "compilerOptions": { "rootDir": "src", "outDir": "dist" },
4
4
  "include": ["src/**/*.ts"],
5
- "exclude": ["dist", "node_modules"]
5
+ "exclude": ["dist", "node_modules", "src/tests"]
6
6
  }