forked from dequelabs/axe-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml-xml-lang-mismatch.js
50 lines (42 loc) · 1.54 KB
/
html-xml-lang-mismatch.js
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
describe('xml-lang-mismatch-matches', function() {
'use strict';
// nested this on a per rule basis, for future-proofing writing tests for multiple rules using the same matches
describe('for rule: html-xml-lang-mismatch', function() {
var rule;
var dom;
var fixture = document.getElementById('fixture');
beforeEach(function() {
rule = axe.utils.getRule('html-xml-lang-mismatch');
dom = document.createElement('html');
});
afterEach(function() {
fixture.innerHTML = '';
});
it('is a function', function() {
var actual = rule.matches;
assert.isFunction(actual);
});
it('returns false if the element does not contain lang or xml:lang attribute', function() {
var actual = rule.matches(dom);
assert.isFalse(actual);
});
it('returns false if the element contains either/ only one of the lang or xml:lang attribute', function() {
dom.setAttribute('lang', 'nl');
var actual = rule.matches(dom);
assert.isFalse(actual);
});
it('returns true if the element contains both lang and xml:lang attribute', function() {
dom.setAttribute('lang', 'en');
dom.setAttribute('xml:lang', 'nl');
var actual = rule.matches(dom);
assert.isTrue(actual);
});
it('returns false for element of type that is not HTML', function() {
var node = document.createElement('svg');
node.setAttribute('lang', '');
node.setAttribute('xml:lang', 'nl');
var actual = rule.matches(node);
assert.isFalse(actual);
});
});
});