diff options
author | Benjamin Jones <bjones@galois.com> | 2013-06-17 00:22:49 -0700 |
---|---|---|
committer | Benjamin Jones <bjones@galois.com> | 2013-06-17 00:22:49 -0700 |
commit | 27e7d5dbd6d6510df67b72f193fbdaaf7e837e59 (patch) | |
tree | 2d9a4d5ae23cc4208844d5306f39ed5a84ace6a3 /exampleData/ruleSets/text | |
parent | 465269594485f4bf61c7475ac0f46c95b7357014 (diff) |
big cleanup and reorganization of exampleData directory; bugfixes to the basic/ rules; added test_basic.html for testing basic UI rules
Diffstat (limited to 'exampleData/ruleSets/text')
-rw-r--r-- | exampleData/ruleSets/text/textRules.json | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/exampleData/ruleSets/text/textRules.json b/exampleData/ruleSets/text/textRules.json new file mode 100644 index 0000000..48853f5 --- /dev/null +++ b/exampleData/ruleSets/text/textRules.json @@ -0,0 +1,57 @@ +{ 'name': 'Text capitalization guidelines' +, 'description': 'Guidelines regarding capitalization of text withing the page' +, 'rules': [ + //--------------------------------------------------------------- + { 'id': 19042301 + , 'name': 'Sentence case' + , 'description': 'Titles should be written in sentence case' + , 'rule': + function() { + var posLength = function(ar) { + return 1 <= ar.length; + }; + + /** + * Test str to see if it is in sentence case. + */ + var assertSentenceCase = function(inStr, elt) { + var str = fiveui.string.trim(inStr); + + if (!fiveui.word.capitalized(str[0])) { + report('The heading: [' + str + '] is not in sentence case.', elt); + return; + } + + var tokens = str.split(' ').filter(posLength); + + for (var i = 1; i < tokens.length; ++i) { + if (fiveui.word.capitalized(tokens[i])) { + report('The heading: [' + str + '] is not in sentence case.', elt); + return; + } + } + }; + + fiveui.query(':header').each(function(idx, elt) { + assertSentenceCase($(elt).text(), elt); + }); + } + }, + //--------------------------------------------------------------- + { 'id': 19042302 + , 'name': 'Capitalization check' + , 'description': 'Capitalize \"Galois\" and \"Galwegian\" when referring to the company' + , 'rule': + function() { + fiveui.query('*').hasText('galois').each(function(i, elt) { + report('\"Galois\" should be capitalized', elt); + }); + + fiveui.query('*').hasText('galwegian').each(function(i, elt) { + report('\"Galwegian\" should be capitalized', elt); + }); + } + }//, + //--------------------------------------------------------------- + ] +} |