Skip to content
This repository has been archived by the owner on Sep 24, 2019. It is now read-only.

Commit

Permalink
Merge pull request #320 from quailjs/2.2/test-patching
Browse files Browse the repository at this point in the history
2 2 test patching
  • Loading branch information
jessebeach committed Aug 8, 2015
2 parents 9cabb02 + bf76766 commit 49c85a9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/js/custom/aImgAltNotRepetitive.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ quail.aImgAltNotRepetitive = function(quail, test, Case) {
element: this
}));
var expected = $(this).closest('.quail-test').data('expected');
if (quail.cleanString($(this).attr('alt')) === quail.cleanString($(this).parent('a').text())) {
var alt = quail.cleanString($(this).attr('alt'));
var linkText = quail.cleanString($(this).closest('a').text());

if (alt.length > 0 && linkText.indexOf(alt) !== -1) {
_case.set({
'expected': expected,
'status': 'failed'
Expand Down
7 changes: 5 additions & 2 deletions src/js/custom/pNotUsedAsHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ quail.pNotUsedAsHeader = function(quail, test, Case) {
});
}
var failed = false;
if ($(this).text().search('.') < 1) {
// Look for any indication that the paragraph contains at least a full sentence
if ($(this).text().search(/[.!:;]/) < 1) {
var $paragraph = $(this),
priorParagraph = $paragraph.prev('p');
// Checking if any of suspectPHeaderTags has exact the same text as a paragraph.
Expand Down Expand Up @@ -40,7 +41,9 @@ quail.pNotUsedAsHeader = function(quail, test, Case) {
}
});
}
if ($paragraph.css('font-weight') === 'bold') {

var fontWeight = $paragraph.css('font-weight');
if (fontWeight === 'bold' || +fontWeight >= 700) { // bold
_case.set({
'status': 'failed'
});
Expand Down
13 changes: 13 additions & 0 deletions test/accessibility-tests/aImgAltNotRepetitive.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,18 @@
<a href="page1.html" class="quail-failed-element"><img src="../assets/rex.jpg" alt="page1"/>page1</a>
</div>

<div class="quail-test" data-expected="fail" data-accessibility-test="aImgAltNotRepetitive">
<a href="page1.html" class="quail-failed-element"><img src="../assets/rex.jpg" alt="page1"/><i>page1</i></a>
</div>

<div class="quail-test" data-expected="fail" data-accessibility-test="aImgAltNotRepetitive">
<a href="page1.html" class="quail-failed-element"><img src="../assets/rex.jpg" alt="page1"/>Go to page1</a>
</div>

<div class="quail-test" data-expected="fail" data-accessibility-test="aImgAltNotRepetitive">
<a href="page1.html" class="quail-failed-element">
<i><img src="../assets/rex.jpg" alt="page1"/></i>page1</a>
</div>

<script src="../quail-testrunner.js"></script> </body>
</html>
9 changes: 9 additions & 0 deletions test/accessibility-tests/pNotUsedAsHeader.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@
</p>
</div>

<div class="quail-test" data-expected="pass" data-accessibility-test="pNotUsedAsHeader">
<p><strong>I am a single sentence paragraph!</strong></p>
</div>

<div class="quail-test" data-expected="pass" data-accessibility-test="pNotUsedAsHeader">

<p>This is a <strong>regular</strong> paragraph</p>
</div>

<div class="quail-test" data-expected="pass" data-accessibility-test="pNotUsedAsHeader">

<p>This is a regular paragraph</p>
Expand Down

0 comments on commit 49c85a9

Please sign in to comment.