Blame view

bower_components/select2/tests/a11y/search-tests.js 1.48 KB
f6e211e4   Administrator   finish work part 1
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
44
45
46
47
48
49
50
51
  module('Accessibility - Search');
  
  var MultipleSelection = require('select2/selection/multiple');
  var InlineSearch = require('select2/selection/search');
  
  var $ = require('jquery');
  
  var Utils = require('select2/utils');
  var Options = require('select2/options');
  var options = new Options({});
  
  test('aria-autocomplete attribute is present', function (assert) {
    var $select = $('#qunit-fixture .multiple');
  
    var CustomSelection = Utils.Decorate(MultipleSelection, InlineSearch);
    var selection = new CustomSelection($select, options);
    var $selection = selection.render();
  
    // Update the selection so the search is rendered
    selection.update([]);
  
    assert.equal(
      $selection.find('input').attr('aria-autocomplete'),
      'list',
      'The search box is marked as autocomplete'
    );
  });
  
  test('aria-activedescendant should be removed when closed', function (assert) {
    var $select = $('#qunit-fixture .multiple');
  
    var CustomSelection = Utils.Decorate(MultipleSelection, InlineSearch);
    var selection = new CustomSelection($select, options);
    var $selection = selection.render();
  
    var container = new MockContainer();
    selection.bind(container, $('<span></span>'));
  
    // Update the selection so the search is rendered
    selection.update([]);
  
    var $search = $selection.find('input');
    $search.attr('aria-activedescendant', 'something');
  
    container.trigger('close');
  
    assert.ok(
      !$search.attr('aria-activedescendant'),
      'There is no active descendant when the dropdown is closed'
    );
  });