Skip to content

Commit bcb67e0

Browse files
authored
Fix hasAria() docs and add hasNoAria() and lacksAria() aliases (mainmatter#1481)
1 parent 8d45db3 commit bcb67e0

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

lib/__tests__/has-aria.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ describe('assert.dom(...).hasAria()', () => {
1515
test('smoke test', () => {
1616
assert.dom('button').hasAria('pressed', 'true');
1717
assert.dom('button').doesNotHaveAria('hidden');
18+
assert.dom('button').hasNoAria('hidden');
19+
assert.dom('button').lacksAria('hidden');
1820

1921
expect(assert.results).toEqual([
2022
{
@@ -29,6 +31,18 @@ describe('assert.dom(...).hasAria()', () => {
2931
message: 'Element button does not have attribute "aria-hidden"',
3032
result: true,
3133
},
34+
{
35+
actual: 'Element button does not have attribute "aria-hidden"',
36+
expected: 'Element button does not have attribute "aria-hidden"',
37+
message: 'Element button does not have attribute "aria-hidden"',
38+
result: true,
39+
},
40+
{
41+
actual: 'Element button does not have attribute "aria-hidden"',
42+
expected: 'Element button does not have attribute "aria-hidden"',
43+
message: 'Element button does not have attribute "aria-hidden"',
44+
result: true,
45+
},
3246
]);
3347
});
3448
});

lib/assertions.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ export default class DOMAssertions {
445445
* @param {string?} message
446446
*
447447
* @example
448-
* assert.dom('input.username').hasNoAttribute('disabled');
448+
* assert.dom('input.username').doesNotHaveAttribute('disabled');
449449
*
450450
* @see {@link #hasAttribute}
451451
*/
@@ -492,7 +492,7 @@ export default class DOMAssertions {
492492
* @example
493493
* assert.dom('button').hasAria('pressed', 'true');
494494
*
495-
* @see {@link #hasNoAria}
495+
* @see {@link #doesNotHaveAria}
496496
*/
497497
hasAria(name: string, value?: string | RegExp | { any: true }, message?: string): DOMAssertions {
498498
return this.hasAttribute(`aria-${name}`, value, message);
@@ -502,6 +502,8 @@ export default class DOMAssertions {
502502
* Assert that the {@link HTMLElement} has no ARIA attribute with the
503503
* provided `name`.
504504
*
505+
* **Aliases:** `hasNoAria`, `lacksAria`
506+
*
505507
* @param {string} name
506508
* @param {string?} message
507509
*
@@ -514,6 +516,14 @@ export default class DOMAssertions {
514516
return this.doesNotHaveAttribute(`aria-${name}`, message);
515517
}
516518

519+
hasNoAria(name: string, message?: string): DOMAssertions {
520+
return this.doesNotHaveAria(name, message);
521+
}
522+
523+
lacksAria(name: string, message?: string): DOMAssertions {
524+
return this.doesNotHaveAria(name, message);
525+
}
526+
517527
/**
518528
* Assert that the {@link HTMLElement} has a property with the provided `name`
519529
* and checks if the property `value` matches the provided text or regular

0 commit comments

Comments
 (0)