summaryrefslogtreecommitdiff
path: root/javascript/videojs/test/unit/tracks/text-track-select.test.js
blob: 059dab63c304d1f23f9980c2e645a2eaece6f248 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* eslint-env qunit */
import TestHelpers from '../test-helpers.js';

const tracks = [{
  kind: 'captions',
  label: 'test'
}];

QUnit.module('Text Track Select');

QUnit.test('should associate with <select>s with <options>s', function(assert) {
  const player = TestHelpers.makePlayer({
    tracks
  });

  const select = player.textTrackSettings.el_.querySelector('select');
  const option = select.querySelector('option');
  const selectAriaLabelledby = select.getAttribute('aria-labelledby');
  const optionAriaLabelledby = option.getAttribute('aria-labelledby');

  assert.ok(
    optionAriaLabelledby.includes(selectAriaLabelledby),
    "select property 'aria-labelledby' is included in its option's property 'aria-labelledby'"
  );
});

QUnit.test('aria-labelledby values must be valid and unique', function(assert) {
  const player = TestHelpers.makePlayer({
    tracks
  });
  const albs = player.$$('.vjs-text-track-settings select[aria-labelledby]');

  albs.forEach(el => {
    const ids = el.getAttribute('aria-labelledby').split(' ');
    const invalidIds = ids.find(id => {
      return !(player.$(`#${id}`));
    });

    assert.notOk(invalidIds, `${el.id} has valid aria-labelledby ids`);

    assert.ok((new Set(ids)).size === ids.length, `${el.id} does not contain duplicate ids`);
  });
});