-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rule): heading and anchor elements should have content (#762)
- Loading branch information
1 parent
bbf7a32
commit 865ec3b
Showing
4 changed files
with
97 additions
and
55 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 was deleted.
Oops, something went wrong.
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,82 @@ | ||
import { getErrorMessage, Rule } from '../src/templateAccessibilityElementsContentRule'; | ||
import { assertAnnotated, assertSuccess } from './testHelper'; | ||
|
||
const { | ||
metadata: { ruleName } | ||
} = Rule; | ||
|
||
describe(ruleName, () => { | ||
describe('failure', () => { | ||
it('should fail with no content in heading tag', () => { | ||
const source = ` | ||
@Component({ | ||
template: \` | ||
<h1 class="size-1"></h1> | ||
~~~~~~~~~~~~~~~~~~~ | ||
\` | ||
}) | ||
class Bar {} | ||
`; | ||
assertAnnotated({ | ||
message: getErrorMessage('h1'), | ||
ruleName, | ||
source | ||
}); | ||
}); | ||
|
||
it('should fail with no content in anchor tag', () => { | ||
const source = ` | ||
@Component({ | ||
template: \` | ||
<a href="#" [routerLink]="['route1']"></a> | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
\` | ||
}) | ||
class Bar {} | ||
`; | ||
assertAnnotated({ | ||
message: getErrorMessage('a'), | ||
ruleName, | ||
source | ||
}); | ||
}); | ||
|
||
it('should fail with no content in anchor tag', () => { | ||
const source = ` | ||
@Component({ | ||
template: \` | ||
<button></button> | ||
~~~~~~~~ | ||
\` | ||
}) | ||
class Bar {} | ||
`; | ||
assertAnnotated({ | ||
message: getErrorMessage('button'), | ||
ruleName, | ||
source | ||
}); | ||
}); | ||
}); | ||
|
||
describe('success', () => { | ||
it('should work when anchor or headings has any kind of content in it', () => { | ||
const source = ` | ||
@Component({ | ||
template: \` | ||
<h1>Heading Content!</h1> | ||
<h2><app-content></app-content></h2> | ||
<h3 [innerHTML]="dangerouslySetHTML"></h3> | ||
<h4 [innerText]="text"></h4> | ||
<a>Anchor Content!</a> | ||
<a><app-content></app-content></a> | ||
<a [innerHTML]="dangerouslySetHTML"></a> | ||
<a [innerText]="text"></a> | ||
\` | ||
}) | ||
class Bar {} | ||
`; | ||
assertSuccess(ruleName, source); | ||
}); | ||
}); | ||
}); |