@vnejs/compatibility.text-with-audio.voice 0.1.2 → 0.1.3
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 +6 -3
- package/src/tests/audio.voice.test.ts +36 -0
- package/src/tests/setup.ts +29 -0
- package/tsconfig.json +12 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vnejs/compatibility.text-with-audio.voice",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
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,9 @@
|
|
|
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",
|
|
43
|
+
"@vnejs/sources-set": "~0.1.0"
|
|
41
44
|
}
|
|
42
45
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { spyEvent } from "@vnejs/test-utils";
|
|
4
|
+
|
|
5
|
+
import { SourcesSet } from "@vnejs/sources-set";
|
|
6
|
+
|
|
7
|
+
import { CompatibilityTextVoice } from "../index.js";
|
|
8
|
+
import { AUDIO_EVENTS, createCompatibilityTestModule, registerCompatibilityVne, TEXT_EVENTS, VOICE_CONST } from "./setup.js";
|
|
9
|
+
|
|
10
|
+
describe("CompatibilityTextVoice", () => {
|
|
11
|
+
beforeEach(() => registerCompatibilityVne());
|
|
12
|
+
|
|
13
|
+
it("TEXT.EMIT with voice plays on voice layer", async () => {
|
|
14
|
+
const { observer } = createCompatibilityTestModule(CompatibilityTextVoice);
|
|
15
|
+
const play = spyEvent(observer, AUDIO_EVENTS.PLAY);
|
|
16
|
+
|
|
17
|
+
await observer.emit(TEXT_EVENTS.EMIT, { args: { voice: "line1" } });
|
|
18
|
+
|
|
19
|
+
expect(play).toHaveBeenCalledOnce();
|
|
20
|
+
expect(play.mock.calls[0]?.[0]).toMatchObject({ layer: VOICE_CONST.LAYER, name: "en/line1" });
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("TEXT.EMIT skips play when voice disable sources are active", async () => {
|
|
24
|
+
const disableSources = new SourcesSet();
|
|
25
|
+
disableSources.set("blocker", true);
|
|
26
|
+
|
|
27
|
+
const { observer } = createCompatibilityTestModule(CompatibilityTextVoice, {
|
|
28
|
+
shared: { voiceDisableSources: disableSources },
|
|
29
|
+
});
|
|
30
|
+
const play = spyEvent(observer, AUDIO_EVENTS.PLAY);
|
|
31
|
+
|
|
32
|
+
await observer.emit(TEXT_EVENTS.EMIT, { args: { voice: "line1" } });
|
|
33
|
+
|
|
34
|
+
expect(play).not.toHaveBeenCalled();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { 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";
|
|
4
|
+
import { createTestModule as baseCreateTestModule, registerCoreVne, registerVnePlugin } from "@vnejs/test-utils";
|
|
5
|
+
import { SourcesSet } from "@vnejs/sources-set";
|
|
6
|
+
|
|
7
|
+
export const registerCompatibilityVne = () => {
|
|
8
|
+
registerCoreVne();
|
|
9
|
+
registerVnePlugin(TEXT, { constants: TEXT_CONST, events: TEXT_EVENTS, params: TEXT_PARAMS, settings: TEXT_SETTINGS });
|
|
10
|
+
registerVnePlugin(AUDIO, { events: AUDIO_EVENTS });
|
|
11
|
+
registerVnePlugin(VOICE, { constants: VOICE_CONST, params: VOICE_PARAMS, settings: VOICE_SETTINGS });
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const createCompatibilityTestModule = <T extends Parameters<typeof baseCreateTestModule>[0]>(
|
|
15
|
+
ModuleClass: T,
|
|
16
|
+
options: Parameters<typeof baseCreateTestModule>[1] = {},
|
|
17
|
+
) =>
|
|
18
|
+
baseCreateTestModule(ModuleClass, {
|
|
19
|
+
state: { currentName: "" },
|
|
20
|
+
shared: {
|
|
21
|
+
settings: { [VOICE_SETTINGS.VOLUME]: 100, [VOICE_SETTINGS.LANG]: "en" },
|
|
22
|
+
voiceLang: "en",
|
|
23
|
+
voiceDisableSources: new SourcesSet(),
|
|
24
|
+
...(options.shared ?? {}),
|
|
25
|
+
},
|
|
26
|
+
...options,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export { AUDIO_EVENTS, TEXT_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
|
}
|