-
Notifications
You must be signed in to change notification settings - Fork 788
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(aria-roledescription): use virtual node (#3570)
* use virtual node
- Loading branch information
Showing
3 changed files
with
143 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
describe('aria-roledescription virtual-rule', function () { | ||
it('should pass for elements with an implicit supported role', function () { | ||
var node = new axe.SerialVirtualNode({ | ||
nodeName: 'button', | ||
attributes: { | ||
'aria-roledescription': 'Awesome Button' | ||
} | ||
}); | ||
|
||
var results = axe.runVirtualRule('aria-roledescription', node); | ||
|
||
assert.lengthOf(results.passes, 1); | ||
assert.lengthOf(results.violations, 0); | ||
assert.lengthOf(results.incomplete, 0); | ||
}); | ||
|
||
it('should pass for elements with an explicit supported role', function () { | ||
var node = new axe.SerialVirtualNode({ | ||
nodeName: 'div', | ||
attributes: { | ||
'aria-roledescription': 'Awesome Radio', | ||
role: 'radio' | ||
} | ||
}); | ||
|
||
var results = axe.runVirtualRule('aria-roledescription', node); | ||
|
||
assert.lengthOf(results.passes, 1); | ||
assert.lengthOf(results.violations, 0); | ||
assert.lengthOf(results.incomplete, 0); | ||
}); | ||
|
||
it('should incomplete for elements with an unsupported role', function () { | ||
var node = new axe.SerialVirtualNode({ | ||
nodeName: 'div', | ||
attributes: { | ||
'aria-roledescription': 'Awesome Main', | ||
role: 'main' | ||
} | ||
}); | ||
|
||
var results = axe.runVirtualRule('aria-roledescription', node); | ||
|
||
assert.lengthOf(results.passes, 0); | ||
assert.lengthOf(results.violations, 0); | ||
assert.lengthOf(results.incomplete, 1); | ||
}); | ||
|
||
it('should fail for elements without role', function () { | ||
var node = new axe.SerialVirtualNode({ | ||
nodeName: 'div', | ||
attributes: { | ||
'aria-roledescription': 'Awesome Main' | ||
} | ||
}); | ||
|
||
var results = axe.runVirtualRule('aria-roledescription', node); | ||
|
||
assert.lengthOf(results.passes, 0); | ||
assert.lengthOf(results.violations, 1); | ||
assert.lengthOf(results.incomplete, 0); | ||
}); | ||
|
||
it('should fail for elements with role=presentation', function () { | ||
var node = new axe.SerialVirtualNode({ | ||
nodeName: 'div', | ||
attributes: { | ||
'aria-roledescription': 'Awesome Main', | ||
role: 'presentation' | ||
} | ||
}); | ||
|
||
var results = axe.runVirtualRule('aria-roledescription', node); | ||
|
||
assert.lengthOf(results.passes, 0); | ||
assert.lengthOf(results.violations, 1); | ||
assert.lengthOf(results.incomplete, 0); | ||
}); | ||
|
||
it('should fail for elements with role=none', function () { | ||
var node = new axe.SerialVirtualNode({ | ||
nodeName: 'div', | ||
attributes: { | ||
'aria-roledescription': 'Awesome Main', | ||
role: 'none' | ||
} | ||
}); | ||
|
||
var results = axe.runVirtualRule('aria-roledescription', node); | ||
|
||
assert.lengthOf(results.passes, 0); | ||
assert.lengthOf(results.violations, 1); | ||
assert.lengthOf(results.incomplete, 0); | ||
}); | ||
}); |