Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Get coverage to 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Aug 1, 2016
1 parent 1bb7c30 commit c26b8f6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ matrix:
before_install:
- npm install -g npm
- npm install -g codeclimate-test-reporter
script: npm run cover
script: npm run travis
addons:
code_climate:
repo_token: 949195dc3763437061a310f7966070b6d9598b47ab437eb0eb180cbce5bcc15a
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@
"cover": "nyc ava",
"lint": "node-version-gte-4 && eslint . || node-version-lt-4",
"precover": "npm run lint && npm run clean",
"postcover": "nyc report -r html -r lcov",
"prepublish": "not-in-install && npm run compile || echo this is npm install",
"postpublish": "git push --follow-tags",
"pretest": "npm run lint",
"pretravis": "npm run precover",
"travis": "nyc --check-coverage --lines 100 --functions 100 --branches 100 --statements 100 ava",
"posttravis": "nyc report -r lcov",
"test": "ava"
},
"ava": {
Expand Down
38 changes: 38 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,41 @@ test('should report filename provided', t => {
t.false(/^undefined$/gm.test(report), 'report should not contains undefined text output');
t.true(report.split('\n')[1] === filename, 'filename should be in output lines');
});

test('should report no violations if there are none', t => {
const res = CSSLint.verify('.class {\n color: red;\n}\n');
const filename = path.resolve('filenamestyle.css');
let report = reporter.startFormat() + reporter.formatResults(res, filename) + reporter.endFormat();

report = chalk.stripColor(report);

t.true(report.trim() === 'No violations', 'report contains text');
});

test('should report errors', t => {
const res = CSSLint.verify('.class {\n color: red !important\n}\n', { important: 2 });
const filename = path.resolve('filenamestyle.css');
let report = reporter.startFormat() + reporter.formatResults(res, filename) + reporter.endFormat();

report = chalk.stripColor(report);

t.regex(report, /line 2/, 'report contains text');
t.regex(report, /char 3/, 'report contains text');
t.regex(report, /Use of !important/, 'report contains text');
t.regex(report, /1 error/, 'report contains text');
});

test('should report rollups correctly', t => {
const res = CSSLint.verify('.class {\n float: left;\n float: left;\n float: left;\n float: left;\n float: left;\n float: left;' +
'\n float: left;\n float: left;\n float: left;\n float: left;\n float: left;\n}\n', { floats: 2 });
const filename = path.resolve('filenamestyle.css');
let report = reporter.startFormat() + reporter.formatResults(res, filename) + reporter.endFormat();

report = chalk.stripColor(report);

t.false(/line /.test(report), 'report does not contains text');
t.false(/char /.test(report), 'report does not contains text');
t.regex(report, /Too many floats \(11\), you're probably using them for layout. Consider using a grid system instead\./,
'report contains text');
t.regex(report, /1 warning/, 'report contains text');
});

0 comments on commit c26b8f6

Please sign in to comment.