Skip to content

Commit

Permalink
update dependencies and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl committed Sep 10, 2016
1 parent fbdf4c2 commit 8202d3f
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 66 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ language: node_js
sudo: false

node_js:
- "0.10"
- "4"
- "6"

Expand Down
2 changes: 1 addition & 1 deletion dist/htmllint.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* HTMLLint v1.1.1 (http://kangax.github.io/html-lint/)
* HTMLLint v2.0.0 (http://kangax.github.io/html-lint/)
* Copyright 2010-2016 Juriy "kangax" Zaytsev
* Licensed under the MIT license
*/
Expand Down
4 changes: 2 additions & 2 deletions dist/htmllint.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<body>
<div id="outer-wrapper">
<div id="wrapper">
<h1>HTML Lint <span>(v1.1.1)</span></h1>
<h1>HTML Lint <span>(v2.0.0)</span></h1>
<textarea rows="8" cols="40" id="input"></textarea>
<div class="lint-button">
<button type="button" id="lint-btn">Lint</button>
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "html-minifier-lint",
"description": "HTML Linter based on HTMLMinifier.",
"version": "1.1.1",
"version": "2.0.0",
"keywords": [
"check",
"checker",
Expand Down Expand Up @@ -43,15 +43,15 @@
"test": "grunt test"
},
"dependencies": {
"html-minifier": "2.x"
"html-minifier": "3.x"
},
"devDependencies": {
"grunt": "1.0.x",
"grunt-browserify": "5.0.x",
"grunt-contrib-uglify": "1.0.x",
"grunt-eslint": "18.1.x",
"grunt-contrib-uglify": "2.0.x",
"grunt-eslint": "19.0.x",
"phantomjs-prebuilt": "2.1.x",
"qunitjs": "1.x"
"qunitjs": "2.x"
},
"files": [
"src/*.js",
Expand Down
4 changes: 2 additions & 2 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<head>
<meta charset="utf-8">
<title>HTML Lint Tests</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-1.23.1.css">
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.0.1.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="https://code.jquery.com/qunit/qunit-1.23.1.js"></script>
<script src="https://code.jquery.com/qunit/qunit-2.0.1.js"></script>
<script src="../dist/htmllint.js"></script>
<script src="lint.js"></script>
</body>
Expand Down
107 changes: 53 additions & 54 deletions tests/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,78 +8,77 @@ if (typeof HTMLLint === 'undefined') {
self.HTMLLint = require('html-minifier-lint').HTMLLint;
}

test('lint exists', function() {
ok(lint);
ok(HTMLLint);
QUnit.test('lint exists', function(assert) {
assert.ok(lint);
assert.ok(HTMLLint);
});

test('lint is instance of HTMLLint', function() {
QUnit.test('lint is instance of HTMLLint', function(assert) {
var lint = new HTMLLint();
ok(lint instanceof HTMLLint);
assert.ok(lint instanceof HTMLLint);
});

test('lint API', function() {
QUnit.test('lint API', function(assert) {
var lint = new HTMLLint();
equal(0, lint.log.length, '`log` property exists');
equal('function', typeof lint.populate, '`populate` method exists');
equal('function', typeof lint.test, '`test` method exists');
equal('function', typeof lint.testElement, '`testElement` method exists');
equal('function', typeof lint.testAttribute, '`testAttribute` method exists');
assert.equal(0, lint.log.length, '`log` property exists');
assert.equal('function', typeof lint.populate, '`populate` method exists');
assert.equal('function', typeof lint.test, '`test` method exists');
assert.equal('function', typeof lint.testElement, '`testElement` method exists');
assert.equal('function', typeof lint.testAttribute, '`testAttribute` method exists');
});

function process(input) {
function process(assert, input) {
var element = {};
lint(input, element);
return element.innerHTML || '';
var log = element.innerHTML || '';
return function(str, count) {
var index = -str.length;
var n = 0;
do {
index = log.indexOf(str, index + str.length);
} while (index !== -1 && ++n);
assert.equal(n, count);
};
}

function match(log, str, count) {
var index = -str.length;
var n = 0;
do {
index = log.indexOf(str, index + str.length);
} while (index !== -1 && ++n);
equal(n, count);
}

test('deprecated attribute', function() {
var log = process('<script language="javascript">foo();</script>');
match(log, 'script', 1);
match(log, 'language', 1);
match(log, 'deprecated-attribute', 1);
log = process('<script type="text/javascript">foo();</script>');
match(log, 'script', 0);
match(log, 'language', 0);
match(log, 'deprecated-attribute', 0);
QUnit.test('deprecated attribute', function(assert) {
var match = process(assert, '<script language="javascript">foo();</script>');
match('script', 1);
match('language', 1);
match('deprecated-attribute', 1);
match = process(assert, '<script type="text/javascript">foo();</script>');
match('script', 0);
match('language', 0);
match('deprecated-attribute', 0);
});

test('deprecated element', function() {
var log = process('<font>foo</font>');
match(log, 'font', 1);
match(log, 'deprecated-element', 1);
log = process('<span>foo</span>');
match(log, 'span', 0);
match(log, 'deprecated-element', 0);
QUnit.test('deprecated element', function(assert) {
var match = process(assert, '<font>foo</font>');
match('font', 1);
match('deprecated-element', 1);
match = process(assert, '<span>foo</span>');
match('span', 0);
match('deprecated-element', 0);
});

test('missing DOCTYPE', function() {
var log = process('<html><head><title>foo</title></head><body>bar</body></html>');
match(log, 'DOCTYPE', 1);
log = process('<!DOCTYPE html><html><head><title>foo</title></head><body>bar</body></html>');
match(log, 'DOCTYPE', 0);
QUnit.test('missing DOCTYPE', function(assert) {
var match = process(assert, '<html><head><title>foo</title></head><body>bar</body></html>');
match('DOCTYPE', 1);
match = process(assert, '<!DOCTYPE html><html><head><title>foo</title></head><body>bar</body></html>');
match('DOCTYPE', 0);
});

test('repeating attribute', function() {
var log = process('<a data-foo="bar" href="/" data-foo="baz">click</a>');
match(log, 'data-foo', 1);
match(log, 'repeating-attribute', 1);
log = process('<a data-foo="bar" href="/" ng-foo="baz">click</a>');
match(log, 'repeating-attribute', 0);
QUnit.test('repeating attribute', function(assert) {
var match = process(assert, '<a data-foo="bar" href="/" data-foo="baz">click</a>');
match('data-foo', 1);
match('repeating-attribute', 1);
match = process(assert, '<a data-foo="bar" href="/" ng-foo="baz">click</a>');
match('repeating-attribute', 0);
});

test('duplicate errors', function() {
var log = process('<font>foo</font>');
match(log, 'DOCTYPE', 1);
match(log, 'font', 1);
match(log, 'deprecated-element', 1);
QUnit.test('duplicate errors', function(assert) {
var match = process(assert, '<font>foo</font>');
match('DOCTYPE', 1);
match('font', 1);
match('deprecated-element', 1);
});

0 comments on commit 8202d3f

Please sign in to comment.