Skip to content

Commit

Permalink
add test spec: Set false to rule
Browse files Browse the repository at this point in the history
add point: load default ruleset when use empty ruleset
  • Loading branch information
yaniswang committed Jun 21, 2014
1 parent f0030cd commit 05167ed
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ HTMLHint change log

## ver 0.9.6 (2014-6-18)

add:

1. add rule: attr-no-duplication
2. add rule: space-tab-mixed-disabled
3. add rule: id-class-ad-disabled
4. add rule: href-abs-or-rel
5. add default rule: attr-no-duplication
6. add inline ruleset support
7. add test spec: Set false to rule
8. add point: load default ruleset when use empty ruleset

## ver 0.9.4 (2013-9-27)

Expand Down
2 changes: 1 addition & 1 deletion coverage.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/htmlhint.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ var HTMLHint = (function (undefined) {
});
return '';
});
ruleset = ruleset || HTMLHint.defaultRuleset;

if(ruleset === undefined || Object.keys(ruleset).length ===0){
ruleset = HTMLHint.defaultRuleset;
}

var parser = new HTMLParser();
var reporter = new HTMLHint.Reporter(html.split(/\r?\n/), ruleset);
Expand Down
16 changes: 15 additions & 1 deletion test/core-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,26 @@ var HTMLHint = require("../index").HTMLHint;

describe('Core', function(){

it('Default ruleset not worked should result in an error', function(){
it('Set false to rule no effected should result in an error', function(){
var code = '<img src="test.gif" />';
var messages = HTMLHint.verify(code, {
'img-alt-require': false
});
expect(messages.length).to.be(0);
});

it('Not load default ruleset when use undefined ruleset should result in an error', function(){
var code = '<P ATTR=\'1\' id="a">><div id="a"><img src="" a="1" a="2"/></div>';
var messages = HTMLHint.verify(code);
expect(messages.length).to.be(9);
});

it('Not load default ruleset when use empty ruleset should result in an error', function(){
var code = '<P ATTR=\'1\' id="a">><div id="a"><img src="" a="1" a="2"/></div>';
var messages = HTMLHint.verify(code, {});
expect(messages.length).to.be(9);
});

it('Inline ruleset not worked should result in an error', function(){
var code = '<!-- htmlhint img-alt-require:true-->\r\n<img src="test.gif" />';
var messages = HTMLHint.verify(code, {
Expand Down

0 comments on commit 05167ed

Please sign in to comment.