Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: improve heading-matches test cases #4586

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions test/rule-matches/heading-matches.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ describe('heading-matches', function () {

beforeEach(function () {
rule = axe.utils.getRule('empty-heading');
assert.isObject(rule, 'Rule object should be available');
assert.isFunction(rule.matches, 'Rule should have a matches function');
});

it('is a function', function () {
Expand All @@ -29,22 +31,22 @@ describe('heading-matches', function () {
}
});

it('should return false on headings with their role changes', function () {
it('should return false on headings that no longer function as headings due to a valid role change', function () {
const vNode = queryFixture('<h1 role="banner" id="target"></h1>');
assert.isFalse(rule.matches(null, vNode));
});

it('should return true on headings with their role changes to an invalid role', function () {
it('should return true on headings with their role changed to an invalid role', function () {
const vNode = queryFixture('<h1 role="bruce" id="target"></h1>');
assert.isTrue(rule.matches(null, vNode));
});

it('should return true on headings with their role changes to an abstract role', function () {
it('should return true on headings with their role changed to an abstract role', function () {
const vNode = queryFixture('<h1 role="widget" id="target"></h1>');
assert.isTrue(rule.matches(null, vNode));
});

it('should return true on headings with explicit role="none" and an empty aria-label to account for presentation conflict resolution', function () {
it('should return true on headings with explicit role="none" and an empty aria-label (handling presentation conflict resolution)', function () {
const vNode = queryFixture(
'<h1 aria-label="" role="none" id="target"></h1>'
);
Expand Down