@vnejs/compatibility.autoread-with-audio.voice 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 +5 -3
- package/src/tests/autoread.voice.test.ts +39 -0
- package/src/tests/setup.ts +18 -0
- package/tsconfig.json +12 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/compatibility.autoread-with-audio.voice",
|
|
3
|
-
"version": "0.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": "
|
|
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",
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
"@vnejs/shared": "~0.1.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@vnejs/configs.ts-common": "~0.1.0"
|
|
40
|
+
"@vnejs/configs.ts-common": "~0.1.0",
|
|
41
|
+
"@vnejs/configs.vitest": "~0.1.0",
|
|
42
|
+
"@vnejs/test-utils": "~0.1.0"
|
|
41
43
|
}
|
|
42
44
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { spyEvent } from "@vnejs/test-utils";
|
|
4
|
+
|
|
5
|
+
import { CompatibilityAutoreadVoice } from "../index.js";
|
|
6
|
+
import { AUTOREAD_EVENTS, AUDIO_EVENTS, createCompatibilityTestModule, registerCompatibilityVne, VOICE_CONST } from "./setup.js";
|
|
7
|
+
|
|
8
|
+
describe("CompatibilityAutoreadVoice", () => {
|
|
9
|
+
beforeEach(() => registerCompatibilityVne());
|
|
10
|
+
|
|
11
|
+
it("AUDIO.PLAY on voice layer emits AUTOREAD.PUSH", async () => {
|
|
12
|
+
const { observer } = createCompatibilityTestModule(CompatibilityAutoreadVoice);
|
|
13
|
+
const push = spyEvent(observer, AUTOREAD_EVENTS.PUSH);
|
|
14
|
+
|
|
15
|
+
await observer.emit(AUDIO_EVENTS.PLAY, { layer: VOICE_CONST.LAYER });
|
|
16
|
+
|
|
17
|
+
expect(push).toHaveBeenCalledOnce();
|
|
18
|
+
expect(push).toHaveBeenCalledWith({ source: VOICE_CONST.SOURCE });
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("AUDIO.STOP on voice layer emits AUTOREAD.POP", async () => {
|
|
22
|
+
const { observer } = createCompatibilityTestModule(CompatibilityAutoreadVoice);
|
|
23
|
+
const pop = spyEvent(observer, AUTOREAD_EVENTS.POP);
|
|
24
|
+
|
|
25
|
+
await observer.emit(AUDIO_EVENTS.STOP, { layer: VOICE_CONST.LAYER });
|
|
26
|
+
|
|
27
|
+
expect(pop).toHaveBeenCalledOnce();
|
|
28
|
+
expect(pop).toHaveBeenCalledWith({ source: VOICE_CONST.SOURCE });
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("AUDIO.PLAY on non-voice layer does nothing", async () => {
|
|
32
|
+
const { observer } = createCompatibilityTestModule(CompatibilityAutoreadVoice);
|
|
33
|
+
const push = spyEvent(observer, AUTOREAD_EVENTS.PUSH);
|
|
34
|
+
|
|
35
|
+
await observer.emit(AUDIO_EVENTS.PLAY, { layer: "music" });
|
|
36
|
+
|
|
37
|
+
expect(push).not.toHaveBeenCalled();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SUBSCRIBE_EVENTS as AUDIO_EVENTS, PLUGIN_NAME as AUDIO } from "@vnejs/contracts.audio";
|
|
2
|
+
import { CONSTANTS as VOICE_CONST, PARAMS as VOICE_PARAMS, PLUGIN_NAME as VOICE, SETTINGS_KEYS as VOICE_SETTINGS } from "@vnejs/contracts.audio.voice";
|
|
3
|
+
import { PARAMS as AUTOREAD_PARAMS, PLUGIN_NAME as AUTOREAD, SETTINGS_KEYS as AUTOREAD_SETTINGS, SUBSCRIBE_EVENTS as AUTOREAD_EVENTS } from "@vnejs/contracts.scenario.autoread";
|
|
4
|
+
import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin } from "@vnejs/test-utils";
|
|
5
|
+
|
|
6
|
+
export const registerCompatibilityVne = () => {
|
|
7
|
+
registerCoreVne();
|
|
8
|
+
registerVnePlugin(AUDIO, { events: AUDIO_EVENTS });
|
|
9
|
+
registerVnePlugin(VOICE, { constants: VOICE_CONST, params: VOICE_PARAMS, settings: VOICE_SETTINGS });
|
|
10
|
+
registerVnePlugin(AUTOREAD, { events: AUTOREAD_EVENTS, params: AUTOREAD_PARAMS, settings: AUTOREAD_SETTINGS });
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const createCompatibilityTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
|
|
14
|
+
ModuleClass: T,
|
|
15
|
+
options: Parameters<typeof baseCreateTestModule>[1] = {},
|
|
16
|
+
) => baseCreateTestModule(ModuleClass, options);
|
|
17
|
+
|
|
18
|
+
export { AUTOREAD_EVENTS, AUDIO_EVENTS, VOICE_CONST };
|
package/tsconfig.json
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"extends": "@vnejs/configs.ts-common/tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "src",
|
|
5
|
+
"outDir": "dist"
|
|
6
|
+
},
|
|
7
|
+
"include": [
|
|
8
|
+
"src/**/*.ts"
|
|
9
|
+
],
|
|
10
|
+
"exclude": [
|
|
11
|
+
"dist",
|
|
12
|
+
"node_modules",
|
|
13
|
+
"src/tests"
|
|
14
|
+
]
|
|
6
15
|
}
|