Skip to content

Commit

Permalink
fix: missing test cases (#327)
Browse files Browse the repository at this point in the history
**Fixes**: #325 

- [x] Check the commit's or even all commits' message styles matches our requested structure.
- [x] Check your code additions will fail neither code linting checks nor unit test.

#### Short description of what this resolves:
In the original pull request some of the test cases were missing. Added --recursive option for mocha to check for all individual rules.
  • Loading branch information
Neo-Zhixing authored and thedaviddias committed Feb 23, 2019
1 parent 85a1c78 commit a344882
Show file tree
Hide file tree
Showing 32 changed files with 35 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ install:
- npm install
script:
- 'npm run build'
- istanbul cover ./node_modules/mocha/bin/_mocha --reporter test -- -R spec
- ./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha -- --recursive
- codecov
branches:
only:
Expand Down
2 changes: 1 addition & 1 deletion dist/htmlhint.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"scripts": {
"commit": "npx git-cz",
"prettier": "prettier --write ./**/*.{js,json,md} --ignore-path ./.prettierignore",
"test": "mocha",
"test": "mocha --recursive",
"build": "webpack",
"travis-deploy-once": "travis-deploy-once",
"semantic-release": "semantic-release"
Expand Down
8 changes: 3 additions & 5 deletions src/reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ class Reporter {
this.ruleset = ruleset;
this.messages = [];

['error', 'warn', 'info'].forEach(type => {
this.error = this.report.bind(this, 'error');
this.warn = this.report.bind(this, 'warn');
this.info = this.report.bind(this, 'info');
});
this.error = this.report.bind(this, 'error');
this.warn = this.report.bind(this, 'warning');
this.info = this.report.bind(this, 'info');
}
report(type, message, line, col, rule, raw) {
var self = this;
Expand Down
2 changes: 1 addition & 1 deletion test/rules/alt-require.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'alt-require';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/attr-lowercase.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'attr-lowercase';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/attr-no-duplication.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'attr-no-duplication';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/attr-unsafe-chars.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'attr-unsafe-chars';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/attr-value-double-quotes.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'attr-value-double-quotes';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/attr-value-not-empty.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'attr-value-not-empty';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/csslint.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'csslint';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/default.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

describe('Rules: default', function() {
it('should result 3 errors', function() {
Expand Down
2 changes: 1 addition & 1 deletion test/rules/doctype-first.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'doctype-first';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/doctype-html5.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'doctype-html5';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/head-require.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'head-script-disabled';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/head-script-disabled.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'head-script-disabled';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/href-abs-or-rel.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'href-abs-or-rel';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/id-class-ad-disabled.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'id-class-ad-disabled';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/id-class-value.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var expect = require("expect.js");

var HTMLHint = require("../../index").HTMLHint;
var HTMLHint = require('../../dist/htmlhint.js').default;

var ruldId = 'id-class-value',
ruleOptionsUnderline = {}, ruleOptionsDash = {}, ruleOptionsHump = {}, ruleOptionsReg = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/id-unique.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'id-unique';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/inline-script-disabled.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'inline-script-disabled';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/inline-style-disabled.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'inline-style-disabled';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/jshint.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'jshint';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/script-disabled.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var expect = require('expect.js'),
HTMLHint = require('../../index').HTMLHint;
HTMLHint = require('../../dist/htmlhint.js').default;
var ruldId = 'script-disabled',
ruleOptions = {};
ruleOptions[ruldId] = true;
Expand Down
2 changes: 1 addition & 1 deletion test/rules/space-tab-mixed-disabled.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'space-tab-mixed-disabled';
const ruleMixOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/spec-char-escape.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var expect = require("expect.js");

var HTMLHint = require("../../index").HTMLHint;
var HTMLHint = require('../../dist/htmlhint.js').default;

var ruldId = 'spec-char-escape',
ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/src-not-empty.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'src-not-empty';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/style-disabled.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'style-disabled';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/tag-pair.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'tag-pair';
const ruleOptions = {};
Expand Down
3 changes: 2 additions & 1 deletion test/rules/tag-self-close.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'tag-self-close';
const ruleOptions = {};
Expand All @@ -15,6 +15,7 @@ describe(`Rules: ${ruldId}`, function() {
expect(messages[0].rule.id).to.be(ruldId);
expect(messages[0].line).to.be(1);
expect(messages[0].col).to.be(1);
console.log('lll', messages[0].type)
expect(messages[0].type).to.be('warning');
expect(messages[1].rule.id).to.be(ruldId);
expect(messages[1].line).to.be(1);
Expand Down
2 changes: 1 addition & 1 deletion test/rules/tagname-lowercase.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'tagname-lowercase';
const ruleOptions = {};
Expand Down
2 changes: 1 addition & 1 deletion test/rules/title-require.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const expect = require('expect.js');

const HTMLHint = require('../../index').HTMLHint;
const HTMLHint = require('../../dist/htmlhint.js').default;

const ruldId = 'title-require';
const ruleOptions = {};
Expand Down

0 comments on commit a344882

Please sign in to comment.