Skip to content

Commit 32bdadf

Browse files
committed
Add muting tests
Signed-off-by: Šimon Brandner <[email protected]>
1 parent 52042cf commit 32bdadf

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

spec/unit/webrtc/callFeed.spec.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
import { SDPStreamMetadataPurpose } from "../../../src/webrtc/callEventTypes";
18+
import { CallFeed } from "../../../src/webrtc/callFeed";
1719
import { TestClient } from "../../TestClient";
20+
import { MockMediaStream, MockMediaStreamTrack } from "../../test-utils/webrtc";
1821

1922
describe("CallFeed", () => {
2023
let client;
@@ -26,4 +29,61 @@ describe("CallFeed", () => {
2629
afterEach(() => {
2730
client.stop();
2831
});
32+
33+
describe("muting", () => {
34+
let feed: CallFeed;
35+
36+
beforeEach(() => {
37+
feed = new CallFeed({
38+
client,
39+
roomId: "room1",
40+
userId: "user1",
41+
// @ts-ignore Mock
42+
stream: new MockMediaStream("stream1"),
43+
purpose: SDPStreamMetadataPurpose.Usermedia,
44+
audioMuted: false,
45+
videoMuted: false,
46+
});
47+
});
48+
49+
describe("should by muted by default", () => {
50+
it("audio", () => {
51+
expect(feed.isAudioMuted()).toBeTruthy();
52+
});
53+
54+
it("video", () => {
55+
expect(feed.isVideoMuted()).toBeTruthy();
56+
});
57+
});
58+
59+
describe("should not be muted after adding track", () => {
60+
it("audio", () => {
61+
// @ts-ignore Mock
62+
feed.stream.addTrack(new MockMediaStreamTrack("track", "audio", true));
63+
expect(feed.isAudioMuted()).toBeFalsy();
64+
});
65+
66+
it("video", () => {
67+
// @ts-ignore Mock
68+
feed.stream.addTrack(new MockMediaStreamTrack("track", "video", true));
69+
expect(feed.isVideoMuted()).toBeFalsy();
70+
});
71+
});
72+
73+
describe("should be muted after calling setAudioVideoMuted()", () => {
74+
it("audio ", () => {
75+
// @ts-ignore Mock
76+
feed.stream.addTrack(new MockMediaStreamTrack("track", "audio", true));
77+
feed.setAudioVideoMuted(true, false);
78+
expect(feed.isAudioMuted()).toBeTruthy();
79+
});
80+
81+
it("video", () => {
82+
// @ts-ignore Mock
83+
feed.stream.addTrack(new MockMediaStreamTrack("track", "video", true));
84+
feed.setAudioVideoMuted(false, true);
85+
expect(feed.isVideoMuted()).toBeTruthy();
86+
});
87+
});
88+
});
2989
});

0 commit comments

Comments
 (0)