Skip to content

Commit

Permalink
Merge pull request #100 from jzaefferer/dev
Browse files Browse the repository at this point in the history
Update vnu.jar, fix tests and minor cleanup
  • Loading branch information
XhmikosR committed Jul 5, 2016
2 parents f154798 + e2e1bc6 commit 291cf04
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 84 deletions.
6 changes: 3 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ root = true
[*]

# Change these settings to your own preference
indent_style = space
indent_size = 2
indent_style = space

# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node_modules
node_modules/
9 changes: 5 additions & 4 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
'preset': 'idiomatic',
'maximumLineLength': false,
'validateLineBreaks': false,
'validateQuoteMarks': "'"
'preset': 'idiomatic',
'maximumLineLength': false,
'validateIndentation': 2,
'validateLineBreaks': false,
'validateQuoteMarks': "'"
}
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ node_js:
- "5"
- "6"


install:
- npm install

Expand Down
2 changes: 1 addition & 1 deletion lib/chunkify.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = function( files, maxChars ) {
var filesChunk = [];
var chunk = '';

for ( var f = 0; f < files.length; f++ ) {
for ( var f = 0, len = files.length; f < len; f++ ) {
if ( chunk.length + ( files[ f ].length + 1 ) > maxChars ) {
filesChunk.push( chunk );
chunk = '';
Expand Down
2 changes: 1 addition & 1 deletion lib/htmllint.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ module.exports = function( config, done ) {
}

var result = [];
for ( var r = 0; r < results.length; r++ ) {
for ( var r = 0, len = results.length; r < len; r++ ) {
result = result.concat( results[ r ] );
}
done( null, result.filter(function( item ) {
Expand Down
2 changes: 1 addition & 1 deletion lib/reporters/checkstyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports = function( results ) {
for ( var fileName in files ) {
if ( files.hasOwnProperty( fileName ) ) {
out.push( '\t<file name="' + fileName + '">' );
for ( var i = 0; i < files[ fileName ].length; i++ ) {
for ( var i = 0, len = files[ fileName ].length; i < len; i++ ) {
var issue = files[ fileName ][ i ];
out.push(
'\t\t<error ' +
Expand Down
16 changes: 8 additions & 8 deletions lib/reporters/junit.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ module.exports = function( results ) {
for ( var fileName in files ) {
if ( files.hasOwnProperty( fileName ) ) {
out.push( '<testcase name="' + fileName + '">\n<error message="' + files[ fileName ].length + ' Errors">' );
for ( var i = 0; i < files[ fileName ].length; i++ ) {
var issue = files[ fileName ][ i ];
out.push(
( i + 1 ) + ' ' +
'line ' + issue.line + ', ' +
'char ' + issue.column + ': ' +
encode( issue.message )
);
for ( var i = 0, len = files[ fileName ].length; i < len; i++ ) {
var issue = files[ fileName ][ i ];
out.push(
( i + 1 ) + ' ' +
'line ' + issue.line + ', ' +
'char ' + issue.column + ': ' +
encode( issue.message )
);
}
out.push( '</error>\n</testcase>' );
}
Expand Down
53 changes: 30 additions & 23 deletions test/html_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,29 +61,36 @@ exports.htmllint = {
},
'bad-encoding': function( test ) {
run( test, {
files: [ 'test/invalid-encoding.html' ],
errorlevels: [ 'info', 'warning', 'error' ]
}, [
{ file: undefined,
type: 'error',
message: 'Malformed byte sequence: “e1”.',
lastLine: 5,
lastColumn: 9 },
{ file: undefined,
type: 'error',
message: 'Malformed byte sequence: “e1”.',
lastLine: 9,
lastColumn: 18 },
{ file: path.join( 'test', 'invalid-encoding.html' ),
type: 'error',
message: 'Internal encoding declaration “iso-8859-1” disagrees with the actual encoding of the document (“utf-8”).',
lastLine: 4,
lastColumn: 74 },
{ file: path.join( 'test', 'invalid-encoding.html' ),
type: 'error',
message: 'Bad value “text/html; charset=iso-8859-1” for attribute “content” on element “meta”: “iso-8859-1” is not a preferred encoding name. The preferred label for this encoding is “windows-1252”.',
lastLine: 4,
lastColumn: 74
files: [ path.join( 'test', 'invalid-encoding.html' ) ],
errorlevels: [ 'info', 'warning', 'error' ]
}, [
{
file: path.join( 'test', 'invalid-encoding.html' ),
type: 'error',
message: 'Malformed byte sequence: “e1”.',
lastLine: 5,
lastColumn: 9
},
{
file: path.join( 'test', 'invalid-encoding.html' ),
type: 'error',
message: 'Malformed byte sequence: “e1”.',
lastLine: 9,
lastColumn: 18
},
{
file: path.join( 'test', 'invalid-encoding.html' ),
type: 'error',
message: 'Internal encoding declaration “iso-8859-1” disagrees with the actual encoding of the document (“utf-8”).',
lastLine: 4,
lastColumn: 74
},
{
file: path.join( 'test', 'invalid-encoding.html' ),
type: 'error',
message: 'Bad value “text/html; charset=iso-8859-1” for attribute “content” on element “meta”: “iso-8859-1” is not a preferred encoding name. The preferred label for this encoding is “windows-1252”.',
lastLine: 4,
lastColumn: 74
}
]);
},
Expand Down
68 changes: 33 additions & 35 deletions test/junit_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,38 @@ var expectedResults = require( './support/expected_results' );
var path = require( 'path' );

exports.junit = {
'junit reporter': {
'when given empty result': function( test ) {
var result = [],
// filename = path.normalize( 'test/invalid.html' ),
expected = [
'<?xml version="1.0" encoding="utf-8"?>',
'<testsuite name="htmllint" tests="0" failures="0" errors="0">',
'</testsuite>'
].join( '\n' ),
actual = reporter( result );
test.equal( actual, expected, 'Should return empty JUnit XML for empty result' );
test.done();
},
'when given non-empty result': function( test ) {
var result = expectedResults.invalid,
filename = path.normalize( 'test/invalid.html' ),
expected = [
'<?xml version="1.0" encoding="utf-8"?>',
'<testsuite name="htmllint" tests="1" failures="0" errors="4">',
'<testcase name="' + filename + '">',
'<error message="4 Errors">',
'1 line 1, char 16: Start tag seen without seeing a doctype first. Expected “&lt;!DOCTYPE html&gt;”.',
'2 line 9, char 96: Attribute “unknownattr” not allowed on element “img” at this point.',
'3 line 9, char 96: An “img” element must have an “alt” attribute, except under certain conditions. For details, consult guidance on providing text alternatives for images.',
'4 line 11, char 19: The “clear” attribute on the “br” element is obsolete. Use CSS instead.',
'</error>',
'</testcase>',
'</testsuite>'
].join( '\n' ),
actual = reporter( result );
test.equal( actual, expected, 'Should report errors as JUnit XML' );
test.done();
}
'junit reporter': {
'when given empty result': function( test ) {
var result = [],
// filename = path.normalize( 'test/invalid.html' ),
expected = [
'<?xml version="1.0" encoding="utf-8"?>',
'<testsuite name="htmllint" tests="0" failures="0" errors="0">',
'</testsuite>'
].join( '\n' ),
actual = reporter( result );
test.equal( actual, expected, 'Should return empty JUnit XML for empty result' );
test.done();
},
'when given non-empty result': function( test ) {
var result = expectedResults.invalid,
filename = path.normalize( 'test/invalid.html' ),
expected = [
'<?xml version="1.0" encoding="utf-8"?>',
'<testsuite name="htmllint" tests="1" failures="0" errors="4">',
'<testcase name="' + filename + '">',
'<error message="4 Errors">',
'1 line 1, char 16: Start tag seen without seeing a doctype first. Expected “&lt;!DOCTYPE html&gt;”.',
'2 line 9, char 96: Attribute “unknownattr” not allowed on element “img” at this point.',
'3 line 9, char 96: An “img” element must have an “alt” attribute, except under certain conditions. For details, consult guidance on providing text alternatives for images.',
'4 line 11, char 19: The “clear” attribute on the “br” element is obsolete. Use CSS instead.',
'</error>',
'</testcase>',
'</testsuite>'
].join( '\n' ),
actual = reporter( result );
test.equal( actual, expected, 'Should report errors as JUnit XML' );
test.done();
}
}
};


12 changes: 6 additions & 6 deletions test/reporters_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@ exports.reporters = {
},
'when checkstyle reporter is specified': function( test ) {
var options = {
reporter: 'checkstyle'
},
reporter: 'checkstyle'
},
reporter = reporters.selectReporter( options ),
checkstyleReporter = require( '../lib/reporters/checkstyle' );
test.equal( reporter, checkstyleReporter, 'Should return checkstyle reporter' );
test.done();
},
'when json reporter is specified': function( test ) {
var options = {
reporter: 'json'
},
reporter: 'json'
},
reporter = reporters.selectReporter( options ),
jsonReporter = require( '../lib/reporters/json' );
test.equal( reporter, jsonReporter, 'Should return json reporter' );
test.done();
},
'when valid custom reporter is specified': function( test ) {
var options = {
reporter: 'test/support/custom_reporter.js'
},
reporter: 'test/support/custom_reporter.js'
},
reporter = reporters.selectReporter( options ),
customReporter = require( './support/custom_reporter' );
test.equal( reporter, customReporter, 'Should return custom reporter' );
Expand Down
Binary file modified vnu.jar
Binary file not shown.

0 comments on commit 291cf04

Please sign in to comment.