When start listening to a broadcast, pause the others (#9489)
This commit is contained in:
@@ -74,7 +74,25 @@ describe("VoiceBroadcastPlayback", () => {
|
||||
|
||||
const itShouldEmitAStateChangedEvent = (state: VoiceBroadcastPlaybackState) => {
|
||||
it(`should emit a ${state} state changed event`, () => {
|
||||
expect(mocked(onStateChanged)).toHaveBeenCalledWith(state);
|
||||
expect(mocked(onStateChanged)).toHaveBeenCalledWith(state, playback);
|
||||
});
|
||||
};
|
||||
|
||||
const startPlayback = () => {
|
||||
beforeEach(async () => {
|
||||
await playback.start();
|
||||
});
|
||||
};
|
||||
|
||||
const pausePlayback = () => {
|
||||
beforeEach(() => {
|
||||
playback.pause();
|
||||
});
|
||||
};
|
||||
|
||||
const stopPlayback = () => {
|
||||
beforeEach(() => {
|
||||
playback.stop();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -180,14 +198,28 @@ describe("VoiceBroadcastPlayback", () => {
|
||||
});
|
||||
|
||||
describe("and calling start", () => {
|
||||
beforeEach(async () => {
|
||||
await playback.start();
|
||||
});
|
||||
startPlayback();
|
||||
|
||||
it("should be in buffering state", () => {
|
||||
expect(playback.getState()).toBe(VoiceBroadcastPlaybackState.Buffering);
|
||||
});
|
||||
|
||||
describe("and calling stop", () => {
|
||||
stopPlayback();
|
||||
itShouldSetTheStateTo(VoiceBroadcastPlaybackState.Stopped);
|
||||
|
||||
describe("and calling pause", () => {
|
||||
pausePlayback();
|
||||
// stopped voice broadcasts cannot be paused
|
||||
itShouldSetTheStateTo(VoiceBroadcastPlaybackState.Stopped);
|
||||
});
|
||||
});
|
||||
|
||||
describe("and calling pause", () => {
|
||||
pausePlayback();
|
||||
itShouldSetTheStateTo(VoiceBroadcastPlaybackState.Paused);
|
||||
});
|
||||
|
||||
describe("and receiving the first chunk", () => {
|
||||
beforeEach(() => {
|
||||
// TODO Michael W: Use RelationsHelper
|
||||
@@ -212,9 +244,7 @@ describe("VoiceBroadcastPlayback", () => {
|
||||
});
|
||||
|
||||
describe("and calling start", () => {
|
||||
beforeEach(async () => {
|
||||
await playback.start();
|
||||
});
|
||||
startPlayback();
|
||||
|
||||
it("should play the last chunk", () => {
|
||||
// assert that the last chunk is played first
|
||||
@@ -258,10 +288,7 @@ describe("VoiceBroadcastPlayback", () => {
|
||||
});
|
||||
|
||||
describe("and calling start", () => {
|
||||
beforeEach(async () => {
|
||||
await playback.start();
|
||||
});
|
||||
|
||||
startPlayback();
|
||||
itShouldSetTheStateTo(VoiceBroadcastPlaybackState.Buffering);
|
||||
});
|
||||
});
|
||||
@@ -278,9 +305,7 @@ describe("VoiceBroadcastPlayback", () => {
|
||||
itShouldSetTheStateTo(VoiceBroadcastPlaybackState.Stopped);
|
||||
|
||||
describe("and calling start", () => {
|
||||
beforeEach(async () => {
|
||||
await playback.start();
|
||||
});
|
||||
startPlayback();
|
||||
|
||||
itShouldSetTheStateTo(VoiceBroadcastPlaybackState.Playing);
|
||||
|
||||
@@ -303,13 +328,15 @@ describe("VoiceBroadcastPlayback", () => {
|
||||
});
|
||||
|
||||
describe("and calling pause", () => {
|
||||
beforeEach(() => {
|
||||
playback.pause();
|
||||
});
|
||||
|
||||
pausePlayback();
|
||||
itShouldSetTheStateTo(VoiceBroadcastPlaybackState.Paused);
|
||||
itShouldEmitAStateChangedEvent(VoiceBroadcastPlaybackState.Paused);
|
||||
});
|
||||
|
||||
describe("and calling stop", () => {
|
||||
stopPlayback();
|
||||
itShouldSetTheStateTo(VoiceBroadcastPlaybackState.Stopped);
|
||||
});
|
||||
});
|
||||
|
||||
describe("and calling toggle for the first time", () => {
|
||||
@@ -337,9 +364,7 @@ describe("VoiceBroadcastPlayback", () => {
|
||||
});
|
||||
|
||||
describe("and calling stop", () => {
|
||||
beforeEach(() => {
|
||||
playback.stop();
|
||||
});
|
||||
stopPlayback();
|
||||
|
||||
itShouldSetTheStateTo(VoiceBroadcastPlaybackState.Stopped);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user