@ray-js/ipc-player-integration 0.0.56-beta.0 → 0.0.56-beta.1
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.
|
@@ -4,7 +4,6 @@ import clsx from 'clsx';
|
|
|
4
4
|
import { useStore } from '../../ctx/store';
|
|
5
5
|
import { UIEventContext } from '../../ui/context';
|
|
6
6
|
import { widgetLabs, widgetClick, pauseTimeToHideAllComponent, startTimeToHideAllComponent } from '../../ui/constant';
|
|
7
|
-
import { IntercomMode } from '../../interface';
|
|
8
7
|
import './muted.less';
|
|
9
8
|
export const Muted = props => {
|
|
10
9
|
const {
|
|
@@ -19,14 +18,12 @@ export const Muted = props => {
|
|
|
19
18
|
const event = propsEvent !== null && propsEvent !== void 0 ? propsEvent : ctxEvent;
|
|
20
19
|
const {
|
|
21
20
|
isMuted,
|
|
22
|
-
intercom
|
|
23
|
-
intercomMode
|
|
21
|
+
intercom
|
|
24
22
|
} = useStore({
|
|
25
23
|
isMuted: mute,
|
|
26
|
-
intercom: props.intercom
|
|
27
|
-
intercomMode: props.intercomMode
|
|
24
|
+
intercom: props.intercom
|
|
28
25
|
});
|
|
29
|
-
const disabled = intercom
|
|
26
|
+
const disabled = intercom;
|
|
30
27
|
return /*#__PURE__*/React.createElement(View, {
|
|
31
28
|
className: clsx(className, {
|
|
32
29
|
'ipc-player-plugin-muted-disabled': disabled
|
|
@@ -27,8 +27,8 @@ const createProps = function () {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
-
it('blocks speaker changes and control events during
|
|
31
|
-
const props = createProps(true);
|
|
30
|
+
it.each([[IntercomMode.OneWay, true], [IntercomMode.OneWay, false], [IntercomMode.TwoWay, true], [IntercomMode.TwoWay, false]])('blocks speaker changes and control events during talk in mode=%s, muted=%s', (mode, muted) => {
|
|
31
|
+
const props = createProps(true, mode, muted);
|
|
32
32
|
const {
|
|
33
33
|
result,
|
|
34
34
|
unmount
|
|
@@ -36,9 +36,10 @@ it('blocks speaker changes and control events during half-duplex talk', () => {
|
|
|
36
36
|
act(() => result.current.props.onClick());
|
|
37
37
|
expect(props.setMute).not.toHaveBeenCalled();
|
|
38
38
|
expect(props.event.emit).not.toHaveBeenCalled();
|
|
39
|
+
expect(result.current.props.className).toContain('ipc-player-plugin-muted-disabled');
|
|
39
40
|
unmount();
|
|
40
41
|
});
|
|
41
|
-
it.each([[false, IntercomMode.OneWay, true, false], [false, IntercomMode.OneWay, false, true], [
|
|
42
|
+
it.each([[false, IntercomMode.OneWay, true, false], [false, IntercomMode.OneWay, false, true], [false, IntercomMode.TwoWay, true, false], [false, IntercomMode.TwoWay, false, true]])('keeps speaker switching when talking=%s, mode=%s, muted=%s', (talking, mode, muted, target) => {
|
|
42
43
|
const props = createProps(talking, mode, muted);
|
|
43
44
|
const {
|
|
44
45
|
result,
|
|
@@ -47,10 +48,11 @@ it.each([[false, IntercomMode.OneWay, true, false], [false, IntercomMode.OneWay,
|
|
|
47
48
|
act(() => result.current.props.onClick());
|
|
48
49
|
expect(props.setMute).toHaveBeenCalledTimes(1);
|
|
49
50
|
expect(props.setMute).toHaveBeenCalledWith(target);
|
|
51
|
+
expect(result.current.props.className).not.toContain('ipc-player-plugin-muted-disabled');
|
|
50
52
|
unmount();
|
|
51
53
|
});
|
|
52
|
-
it('uses shared talk state after remount and unlocks when talk ends',
|
|
53
|
-
const props = createProps();
|
|
54
|
+
it.each([IntercomMode.OneWay, IntercomMode.TwoWay])('uses shared talk state after remount and unlocks when talk ends in mode=%s', mode => {
|
|
55
|
+
const props = createProps(false, mode);
|
|
54
56
|
const store = getDefaultStore();
|
|
55
57
|
const first = renderHook(() => Muted(props));
|
|
56
58
|
act(() => store.set(props.intercom, true));
|
|
@@ -65,14 +67,15 @@ it('uses shared talk state after remount and unlocks when talk ends', () => {
|
|
|
65
67
|
expect(props.setMute).toHaveBeenCalledWith(false);
|
|
66
68
|
second.unmount();
|
|
67
69
|
});
|
|
68
|
-
it('
|
|
69
|
-
const props = createProps(true);
|
|
70
|
+
it.each([[IntercomMode.OneWay, IntercomMode.TwoWay], [IntercomMode.TwoWay, IntercomMode.OneWay]])('keeps the speaker locked when active talk changes from %s to %s', (mode, nextMode) => {
|
|
71
|
+
const props = createProps(true, mode);
|
|
70
72
|
const {
|
|
71
73
|
result,
|
|
72
74
|
unmount
|
|
73
75
|
} = renderHook(() => Muted(props));
|
|
74
|
-
act(() => getDefaultStore().set(props.intercomMode,
|
|
76
|
+
act(() => getDefaultStore().set(props.intercomMode, nextMode));
|
|
75
77
|
act(() => result.current.props.onClick());
|
|
76
|
-
expect(props.setMute).
|
|
78
|
+
expect(props.setMute).not.toHaveBeenCalled();
|
|
79
|
+
expect(props.event.emit).not.toHaveBeenCalled();
|
|
77
80
|
unmount();
|
|
78
81
|
});
|