-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlabel-matches.js
More file actions
45 lines (36 loc) · 1.38 KB
/
label-matches.js
File metadata and controls
45 lines (36 loc) · 1.38 KB
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
describe('label-matches', function () {
'use strict';
const fixture = document.getElementById('fixture');
const queryFixture = axe.testUtils.queryFixture;
let rule;
beforeEach(function () {
fixture.innerHTML = '';
rule = axe.utils.getRule('label');
});
it('returns true for non-input elements', function () {
const vNode = queryFixture('<textarea id="target"></textarea>');
assert.isTrue(rule.matches(null, vNode));
});
it('returns true for input elements without type', function () {
const vNode = queryFixture('<input id="target" />');
assert.isTrue(rule.matches(null, vNode));
});
it('returns false for input buttons', function () {
['button', 'submit', 'image', 'reset'].forEach(function (type) {
const vNode = queryFixture('<input id="target" type="' + type + '" />');
assert.isFalse(rule.matches(null, vNode));
});
});
it('returns false for input elements type=hidden', function () {
const vNode = queryFixture('<input id="target" type="hidden" />');
assert.isFalse(rule.matches(null, vNode));
});
it('returns true for other input types', function () {
['text', 'password', 'url', 'range', 'date', 'checkbox', 'radio'].forEach(
function (type) {
const vNode = queryFixture('<input id="target" type="' + type + '" />');
assert.isTrue(rule.matches(null, vNode));
}
);
});
});