1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-23 02:04:34 +02:00
video.js/test/unit/tracks/track-baseline.js
claudiah12 ee0637c078
feat(track): make label property mutable and fire a labelchange event when the label is changed (#6928)
Allows the editing of a track's label after its creation. Menu buttons will listen for the labelchange event and update their content accordingly.

This is technically divergent from the spec, which says it's readonly, but it can be useful for Video.js users.

Co-authored-by: Claudia Hinkle <chinkle@chinkle-mn1.linkedin.biz>
2020-11-10 18:11:53 -05:00

50 lines
1.5 KiB
JavaScript

/* eslint-env qunit */
import TechFaker from '../tech/tech-faker';
/**
* Tests baseline functionality for all tracks
*
# @param {Track} TrackClass the track class object to use for testing
# @param {Object} options the options to setup a track with
*/
const TrackBaseline = function(TrackClass, options) {
QUnit.test('is setup with id, kind, label, and language', function(assert) {
const tech = new TechFaker();
const track = new TrackClass(Object.assign({tech}, options));
assert.equal(track.kind, options.kind, 'we have a kind');
assert.equal(track.label, options.label, 'we have a label');
assert.equal(track.language, options.language, 'we have a language');
assert.equal(track.id, options.id, 'we have a id');
tech.dispose();
});
QUnit.test('kind, language, id, are read only', function(assert) {
const tech = new TechFaker();
const track = new TrackClass(Object.assign({tech}, options));
track.kind = 'subtitles';
track.language = 'es';
track.id = '2';
assert.equal(track.kind, options.kind, 'we have a kind');
assert.equal(track.language, options.language, 'we have a language');
assert.equal(track.id, options.id, 'we have an id');
tech.dispose();
});
QUnit.test('returns an instance of itself on non ie8 browsers', function(assert) {
const tech = new TechFaker();
const track = new TrackClass(Object.assign({tech}, options));
assert.ok(track instanceof TrackClass, 'returns an instance');
tech.dispose();
});
};
export default TrackBaseline;