Skip to content

Commit

Permalink
test: update expectation tests for Chrome v116
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisguttandin committed Aug 29, 2023
1 parent 31c6d03 commit e9b5f46
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 81 deletions.
2 changes: 1 addition & 1 deletion config/karma/config-expectation-chrome-penultimate.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ module.exports = (config) => {
}
});

env.CHROME_BIN = 'chromium-v113/chrome-mac/Chromium.app/Contents/MacOS/Chromium';
env.CHROME_BIN = 'chromium-v114/chrome-mac/Chromium.app/Contents/MacOS/Chromium';
};
2 changes: 1 addition & 1 deletion config/karma/config-expectation-chrome-previous.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ module.exports = (config) => {
}
});

env.CHROME_BIN = 'chromium-v114/chrome-mac/Chromium.app/Contents/MacOS/Chromium';
env.CHROME_BIN = 'chromium-v115/chrome-mac/Chromium.app/Contents/MacOS/Chromium';
};
80 changes: 1 addition & 79 deletions test/expectation/chrome/penultimate/media-recorder.js
Original file line number Diff line number Diff line change
@@ -1,67 +1,16 @@
import { AudioContext } from 'standardized-audio-context';
import { createMediaStreamWithAudioTrack } from '../../../helpers/create-media-stream-with-audio-track';
import { createMediaStreamWithVideoTrack } from '../../../helpers/create-media-stream-with-video-track';
import { recordAboutASecondOfAudio } from '../../../helpers/record-about-a-second-of-audio';
import { spy } from 'sinon';

describe('module', () => {
describe('with a MediaStream which contains an audio track', () => {
let audioContext;
let mediaRecorder;
let mediaStream;

afterEach(() => {
audioContext.close();
mediaStream.getTracks().forEach((track) => track.stop());
});

beforeEach(async () => {
beforeEach(() => {
audioContext = new AudioContext();
mediaStream = await createMediaStreamWithAudioTrack(audioContext);
mediaRecorder = new MediaRecorder(mediaStream);
});

// bug #7

it('should fire an error event after the dataavailable and stop events when adding a track', function (done) {
this.timeout(10000);

const ondataavailable = spy();
const onstop = spy();

mediaRecorder.addEventListener('dataavailable', ondataavailable);
mediaRecorder.addEventListener('error', () => {
expect(ondataavailable).to.have.been.calledOnce;
expect(onstop).to.have.been.calledOnce;

done();
});
mediaRecorder.addEventListener('stop', onstop);
mediaRecorder.start();

createMediaStreamWithAudioTrack(audioContext).then((anotherMediaStream) =>
mediaStream.addTrack(anotherMediaStream.getAudioTracks()[0])
);
});

// bug #8

it('should fire an error event after the dataavailable and stop events when removing a track', function (done) {
this.timeout(10000);

const ondataavailable = spy();
const onstop = spy();

mediaRecorder.addEventListener('dataavailable', ondataavailable);
mediaRecorder.addEventListener('error', () => {
expect(ondataavailable).to.have.been.calledOnce;
expect(onstop).to.have.been.calledOnce;

done();
});
mediaRecorder.addEventListener('stop', onstop);
mediaRecorder.start();
mediaStream.removeTrack(mediaStream.getAudioTracks()[0]);
});

// bug #9
Expand All @@ -74,31 +23,4 @@ describe('module', () => {
).to.be.above(1);
});
});

describe('with a MediaStream which contains a video track', () => {
let mediaStream;
let mediaRecorder;

afterEach(() => mediaStream.getTracks().forEach((track) => track.stop()));

beforeEach(() => {
mediaStream = createMediaStreamWithVideoTrack();
mediaRecorder = new MediaRecorder(mediaStream, { mimeType: 'audio/webm' });
});

// bug #6

it('should emit a blob without any data', function (done) {
this.timeout(10000);

mediaRecorder.addEventListener('dataavailable', ({ data }) => {
expect(data.size).to.equal(0);

done();
});
mediaRecorder.start();

setTimeout(() => mediaRecorder.stop(), 1000);
});
});
});

0 comments on commit e9b5f46

Please sign in to comment.