Skip to content

Commit

Permalink
tests: add virtual-rules test for tabindex (#2750)
Browse files Browse the repository at this point in the history
  • Loading branch information
straker authored Jan 14, 2021
1 parent 8cc8c97 commit da8b37c
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/integration/virtual-rules/tabindex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
describe('tabindex virtual-rule', function() {
it('should pass for tabindex = 0', function() {
var node = {
nodeName: 'div',
attributes: {
tabindex: 0
}
};

var results = axe.runVirtualRule('tabindex', node);

assert.lengthOf(results.passes, 1);
assert.lengthOf(results.violations, 0);
assert.lengthOf(results.incomplete, 0);
});

it('should pass for tabindex = -1', function() {
var node = {
nodeName: 'div',
attributes: {
tabindex: -1
}
};

var results = axe.runVirtualRule('tabindex', node);

assert.lengthOf(results.passes, 1);
assert.lengthOf(results.violations, 0);
assert.lengthOf(results.incomplete, 0);
});

it('should fail for tabindex > 0', function() {
var node = {
nodeName: 'div',
attributes: {
tabindex: 1
}
};

var results = axe.runVirtualRule('tabindex', node);

assert.lengthOf(results.passes, 0);
assert.lengthOf(results.violations, 1);
assert.lengthOf(results.incomplete, 0);
});
});

0 comments on commit da8b37c

Please sign in to comment.