Skip to content

Commit

Permalink
enhancing language selection tests, making them more sensitive, addin…
Browse files Browse the repository at this point in the history
…g case with 3-letter code, using RegExp object instead of string with RegExp
  • Loading branch information
Stephan Schreiner authored and stschr committed Aug 30, 2022
1 parent 9314135 commit 04c0217
Showing 1 changed file with 60 additions and 59 deletions.
119 changes: 60 additions & 59 deletions test/unit/streaming.controllers.MediaController.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,99 +334,100 @@ describe('MediaController', function () {
});

describe('Initial Track Management', function () {
let streamInfo = {
id: 'id'
};
let frTrack = {
type: trackType,
streamInfo: streamInfo,
lang: 'fr',
viewpoint: 'viewpoint',
roles: 1,
accessibility: 1,
audioChannelConfiguration: 1
};
const qtzTrack = {
type: trackType,
streamInfo: streamInfo,
lang: 'qtz',
viewpoint: 'viewpoint',
roles: 1,
accessibility: 1,
audioChannelConfiguration: 1
};

it('should check initial media settings to choose initial track', function () {
let streamInfo = {
id: 'id'
};
let track = {
type: trackType,
streamInfo: streamInfo,
lang: 'fr',
viewpoint: 'viewpoint',
roles: 1,
accessibility: 1,
audioChannelConfiguration: 1
};
mediaController.addTrack(frTrack);
mediaController.addTrack(qtzTrack);

mediaController.addTrack(track);
let trackList = mediaController.getTracksFor(trackType, streamInfo.id);
expect(trackList).to.have.lengthOf(2);
expect(objectUtils.areEqual(trackList[0], frTrack)).to.be.true; // jshint ignore:line
expect(objectUtils.areEqual(trackList[1], qtzTrack)).to.be.true; // jshint ignore:line

let currentTrack = mediaController.getCurrentTrackFor(trackType, streamInfo.id);
expect(objectUtils.areEqual(currentTrack, frTrack)).to.be.false; // jshint ignore:line

// call to setInitialMediaSettingsForType
mediaController.setInitialSettings(trackType, {
lang: 'qtz',
viewpoint: 'viewpoint'
});
mediaController.setInitialMediaSettingsForType(trackType, streamInfo);

currentTrack = mediaController.getCurrentTrackFor(trackType, streamInfo.id);
expect(objectUtils.areEqual(currentTrack, qtzTrack)).to.be.true; // jshint ignore:line

});

it('should check initial media settings to choose initial track with 639-2 3-letter code', function () {
mediaController.addTrack(qtzTrack);
mediaController.addTrack(frTrack);

let trackList = mediaController.getTracksFor(trackType, streamInfo.id);
expect(trackList).to.have.lengthOf(1);
expect(objectUtils.areEqual(trackList[0], track)).to.be.true; // jshint ignore:line
expect(trackList).to.have.lengthOf(2);
expect(objectUtils.areEqual(trackList[0], qtzTrack)).to.be.true; // jshint ignore:line
expect(objectUtils.areEqual(trackList[1], frTrack)).to.be.true; // jshint ignore:line

let currentTrack = mediaController.getCurrentTrackFor(trackType, streamInfo.id);
expect(objectUtils.areEqual(currentTrack, track)).to.be.false; // jshint ignore:line
expect(objectUtils.areEqual(currentTrack, frTrack)).to.be.false; // jshint ignore:line

// call to setInitialMediaSettingsForType
mediaController.setInitialSettings(trackType, {
lang: 'fr',
lang: 'fre',
viewpoint: 'viewpoint'
});
mediaController.setInitialMediaSettingsForType(trackType, streamInfo);

currentTrack = mediaController.getCurrentTrackFor(trackType, streamInfo.id);
expect(objectUtils.areEqual(currentTrack, track)).to.be.true; // jshint ignore:line
expect(objectUtils.areEqual(currentTrack, frTrack)).to.be.true; // jshint ignore:line

});

it('should check initial media settings to choose initial track with a string/regex lang', function () {
const streamInfo = {
id: 'id'
};
const track = {
type: trackType,
streamInfo: streamInfo,
lang: 'fr',
viewpoint: 'viewpoint',
roles: 1,
accessibility: 1,
audioChannelConfiguration: 1
};

mediaController.addTrack(track);
mediaController.addTrack(frTrack);
mediaController.addTrack(qtzTrack);

let trackList = mediaController.getTracksFor(trackType, streamInfo.id);
expect(trackList).to.have.lengthOf(1);
expect(objectUtils.areEqual(trackList[0], track)).to.be.true; // jshint ignore:line
expect(trackList).to.have.lengthOf(2);
expect(objectUtils.areEqual(trackList[0], frTrack)).to.be.true; // jshint ignore:line
expect(objectUtils.areEqual(trackList[1], qtzTrack)).to.be.true; // jshint ignore:line

let currentTrack = mediaController.getCurrentTrackFor(trackType, streamInfo.id);
expect(objectUtils.areEqual(currentTrack, track)).to.be.false; // jshint ignore:line
expect(objectUtils.areEqual(currentTrack, frTrack)).to.be.false; // jshint ignore:line

// call to setInitialMediaSettingsForType
mediaController.setInitialSettings(trackType, {
lang: 'fr|en|qtz',
lang: /fr|en|qtz/,
viewpoint: 'viewpoint'
});
mediaController.setInitialMediaSettingsForType(trackType, streamInfo);

currentTrack = mediaController.getCurrentTrackFor(trackType, streamInfo.id);
expect(objectUtils.areEqual(currentTrack, track)).to.be.true; // jshint ignore:line
expect(objectUtils.areEqual(currentTrack, frTrack)).to.be.true; // jshint ignore:line
});

it('should check initial media settings to choose initial track with a regex lang', function () {
const streamInfo = {
id: 'id'
};
const frTrack = {
type: trackType,
streamInfo: streamInfo,
lang: 'fr',
viewpoint: 'viewpoint',
roles: 1,
accessibility: 1,
audioChannelConfiguration: 1
};
const qtzTrack = {
type: trackType,
streamInfo: streamInfo,
lang: 'qtz',
viewpoint: 'viewpoint',
roles: 1,
accessibility: 1,
audioChannelConfiguration: 1
};

mediaController.addTrack(frTrack);
mediaController.addTrack(qtzTrack);

Expand Down

0 comments on commit 04c0217

Please sign in to comment.