@webex/internal-plugin-voicea 3.11.0 → 3.12.0-llmrefactor.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.
@@ -0,0 +1,71 @@
1
+ import MockWebex from '@webex/test-helper-mock-webex';
2
+ import {assert} from '@webex/test-helper-chai';
3
+ import sinon from 'sinon';
4
+ import Mercury from '@webex/internal-plugin-mercury';
5
+ import LLMChannel from '@webex/internal-plugin-llm';
6
+
7
+ import {VoiceaPlugin} from '@webex/internal-plugin-voicea/src/voicea-plugin';
8
+ import {VoiceaChannel} from '@webex/internal-plugin-voicea/src/voicea';
9
+
10
+ /**
11
+ * Creates a mock LLM channel for testing
12
+ * @returns {Object} Mock channel
13
+ */
14
+ function createMockLLMChannel() {
15
+ return {
16
+ isConnected: sinon.stub().returns(true),
17
+ getSocket: sinon.stub().returns({}),
18
+ getBinding: sinon.stub().returns('binding'),
19
+ getDatachannelUrl: sinon.stub().returns('datachannelUrl'),
20
+ getLocusUrl: sinon.stub().returns('locusUrl'),
21
+ isDataChannelTokenEnabled: sinon.stub().resolves(true),
22
+ on: sinon.stub(),
23
+ off: sinon.stub(),
24
+ };
25
+ }
26
+
27
+ describe('plugin-voicea', () => {
28
+ describe('VoiceaPlugin', () => {
29
+ let webex;
30
+ let plugin;
31
+
32
+ beforeEach(() => {
33
+ webex = new MockWebex({
34
+ children: {
35
+ mercury: Mercury,
36
+ llm: LLMChannel,
37
+ },
38
+ });
39
+
40
+ plugin = new VoiceaPlugin({}, {parent: webex});
41
+ });
42
+
43
+ afterEach(() => sinon.restore());
44
+
45
+ describe('#createChannel', () => {
46
+ it('creates a new VoiceaChannel instance', () => {
47
+ const mockLLMChannel = createMockLLMChannel();
48
+
49
+ const channel = plugin.createChannel(mockLLMChannel);
50
+
51
+ assert.instanceOf(channel, VoiceaChannel);
52
+ });
53
+
54
+ it('creates independent channels for multiple calls', () => {
55
+ const mockLLMChannel1 = createMockLLMChannel();
56
+ const mockLLMChannel2 = createMockLLMChannel();
57
+
58
+ const channel1 = plugin.createChannel(mockLLMChannel1);
59
+ const channel2 = plugin.createChannel(mockLLMChannel2);
60
+
61
+ assert.notStrictEqual(channel1, channel2);
62
+ });
63
+ });
64
+
65
+ describe('namespace', () => {
66
+ it('has the correct namespace', () => {
67
+ assert.equal(plugin.namespace, 'voicea');
68
+ });
69
+ });
70
+ });
71
+ });