diff --git a/doc/check-options.md b/doc/check-options.md index 17f5adac6c..392c1e02e1 100644 --- a/doc/check-options.md +++ b/doc/check-options.md @@ -415,8 +415,25 @@ h6:not([role]), { "size": 1.4 } ] -
passLength
+ "passLength": 1
+ faiLength
+ "failLength": 0.5
+ elements are not styled as headings", - "fail": "Heading elements should be used instead of styled p elements" + "fail": "Heading elements should be used instead of styled
elements", + "incomplete": "Unable to determine if
elements are styled as headings" } } } diff --git a/test/checks/navigation/p-as-heading.js b/test/checks/navigation/p-as-heading.js index 97d1fde38b..40edbfef05 100644 --- a/test/checks/navigation/p-as-heading.js +++ b/test/checks/navigation/p-as-heading.js @@ -36,7 +36,7 @@ describe('p-as-heading', function() { it('returns false if the font-weight is heavier', function() { var params = checkSetup( - '
elm 1
' + 'elm 2
', + 'elm 1
' + 'elm 2elm 2
', testOptions ); assert.isFalse( @@ -46,7 +46,7 @@ describe('p-as-heading', function() { it('returns false if the font-size is bigger', function() { var params = checkSetup( - 'elm 1
elm 2
', + 'elm 1
elm 2elm 2
', testOptions ); assert.isFalse( @@ -56,7 +56,7 @@ describe('p-as-heading', function() { it('returns false if the fake heading is italic and the text is not', function() { var params = checkSetup( - 'elm 1
elm 2
', + 'elm 1
elm 2elm 2
', testOptions ); assert.isFalse( @@ -67,7 +67,7 @@ describe('p-as-heading', function() { it('returns true if both texts are bold, italic and larger', function() { var params = checkSetup( 'elm 1
' + - 'elm 2
', + 'elm 2elm 2
', testOptions ); assert.isTrue( @@ -77,7 +77,7 @@ describe('p-as-heading', function() { it('considers styles of elements inside the paragraph', function() { var params = checkSetup( - 'elm 1
elm 2
', + 'elm 1
elm 2elm 2
', testOptions ); assert.isFalse( @@ -87,7 +87,7 @@ describe('p-as-heading', function() { it('ignores empty child element for style', function() { var params = checkSetup( - 'elm 1
elm 2
', + 'elm 1
elm 2elm 2
', testOptions ); assert.isFalse( @@ -97,7 +97,7 @@ describe('p-as-heading', function() { it('considers styles of elements that do not contain all the text', function() { var params = checkSetup( - 'elm 1
elm 2
', + 'elm 1
elm 2elm 2
', testOptions ); assert.isTrue( @@ -108,7 +108,7 @@ describe('p-as-heading', function() { it('returns undefined instead of false if the element is inside a blockquote', function() { var params = checkSetup( '' + - '', testOptions ); @@ -120,7 +120,7 @@ describe('p-as-heading', function() { it('returns true over undefined from within a blockquote', function() { var params = checkSetup( 'elm 1
elm 2
' + + 'elm 1
elm 2elm 2
' + '
' + - '', testOptions ); @@ -141,12 +141,68 @@ describe('p-as-heading', function() { ); }); + it('returns true if the heading is greater than the paragraph', function() { + var params = checkSetup( + 'elm 1
elm 2
' + + 'elm 1
elm 2elm 2
' + '
elm1elm1
' + 'elm2
', + testOptions + ); + assert.isTrue( + axe.testUtils.getCheckEvaluate('p-as-heading').apply(checkContext, params) + ); + }); + + it('returns undefined if the heading is twice as long but not greater than the length of the pararaph', function() { + var params = checkSetup( + 'elm1elm
' + 'elm2elm2
', + testOptions + ); + assert.isUndefined( + axe.testUtils.getCheckEvaluate('p-as-heading').apply(checkContext, params) + ); + }); + + describe('options.passLength and options.failLength', function() { + it('returns true if the heading is greater than the paragraph using options.passLength', function() { + var options = { + margins: [{ weight: 100 }, { italic: true }, { size: 1.2 }], + passLength: 2 + }; + + var params = checkSetup( + 'elm1elm1elm1
' + 'elm2
', + options + ); + assert.isTrue( + axe.testUtils + .getCheckEvaluate('p-as-heading') + .apply(checkContext, params) + ); + }); + + it('returns undefined if the heading is twice as long but not greater than the length of the pararaph using options.failLength ', function() { + var options = { + margins: [{ weight: 100 }, { italic: true }, { size: 1.2 }], + failLength: 0.6 + }; + var params = checkSetup( + 'elm1elm
' + + 'elm2elm2elm2
', + options + ); + assert.isFalse( + axe.testUtils + .getCheckEvaluate('p-as-heading') + .apply(checkContext, params) + ); + }); + }); + describe('option.margin', function() { it('passes if no margins are set', function() { var options = {}; var params = checkSetup( - 'elm 1
elm 2
', + 'elm 1
elm 2elm 2
', options ); assert.isTrue( @@ -162,7 +218,7 @@ describe('p-as-heading', function() { }; var params = checkSetup( - 'elm 1
elm 2
', + 'elm 1
elm 2elm 2
', options ); assert.isTrue( @@ -179,7 +235,7 @@ describe('p-as-heading', function() { var params = checkSetup( 'elm 1
' + - 'elm 2
', + 'elm 2elm 2
', options ); assert.isFalse( @@ -211,7 +267,8 @@ describe('p-as-heading', function() { }; var params = checkSetup( - 'elm 1
' + 'elm 2
', + 'elm 1
' + + 'elm 2elm 2
', options ); assert.isFalse( diff --git a/test/integration/rules/p-as-heading/p-as-heading.html b/test/integration/rules/p-as-heading/p-as-heading.html index 5ffd17d5a0..1be3c19860 100644 --- a/test/integration/rules/p-as-heading/p-as-heading.html +++ b/test/integration/rules/p-as-heading/p-as-heading.html @@ -43,29 +43,34 @@A paragraph!
+Hello World
+Hello
+Some text
-A paragraph!
+A paragraph, A paragraph!
Some text
-A paragraph!
+A paragraph, A paragraph!
Some text
-A paragraph!
+A paragraph, A paragraph!
Some text
Some text
-A paragraph!
+A paragraph, A paragraph!