This repository has been archived by the owner on Nov 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
93 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"extends": "standard" | ||
"extends": "simenb-base" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,79 @@ | ||
/* eslint-env mocha */ | ||
/* eslint import/no-extraneous-dependencies: ["error", { "devDependencies": true }] */ | ||
|
||
import reporter from './stylish' | ||
import { CSSLint } from 'csslint'; | ||
import chalk from 'chalk'; | ||
|
||
import { CSSLint } from 'csslint' | ||
import chalk from 'chalk' | ||
import path from 'path'; | ||
import assert from 'assert'; | ||
|
||
import path from 'path' | ||
import assert from 'assert' | ||
import reporter from './stylish'; | ||
|
||
describe('csslint-stylish', () => { | ||
it('should report stuff', () => { | ||
const res = CSSLint.verify('.class {\n color: red !important\n}\n') | ||
const res = CSSLint.verify('.class {\n color: red !important\n}\n'); | ||
|
||
let report = reporter.startFormat() + reporter.formatResults(res, path.resolve('style.css')) + reporter.endFormat() | ||
let report = reporter.startFormat() + reporter.formatResults(res, path.resolve('style.css')) + reporter.endFormat(); | ||
|
||
report = chalk.stripColor(report) | ||
report = chalk.stripColor(report); | ||
|
||
const filename = report.split('\n')[1] | ||
const filename = report.split('\n')[1]; | ||
|
||
assert(filename === 'style.css', 'filename is correct') | ||
assert(report.match(/line 2/), 'report contains text') | ||
assert(report.match(/char 3/), 'report contains text') | ||
assert(report.match(/Use of !important/), 'report contains text') | ||
assert(report.match(/1 warning/), 'report contains text') | ||
}) | ||
assert(filename === 'style.css', 'filename is correct'); | ||
assert(report.match(/line 2/), 'report contains text'); | ||
assert(report.match(/char 3/), 'report contains text'); | ||
assert(report.match(/Use of !important/), 'report contains text'); | ||
assert(report.match(/1 warning/), 'report contains text'); | ||
}); | ||
|
||
it('should report with full path', () => { | ||
const res = CSSLint.verify('.class {\n color: red !important\n}\n') | ||
const res = CSSLint.verify('.class {\n color: red !important\n}\n'); | ||
|
||
let report = reporter.startFormat() + reporter.formatResults(res, path.resolve('style.css'), | ||
{absoluteFilePathsForFormatters: true}) + reporter.endFormat() | ||
{ absoluteFilePathsForFormatters: true }) + reporter.endFormat(); | ||
|
||
report = chalk.stripColor(report) | ||
report = chalk.stripColor(report); | ||
|
||
const filename = report.split('\n')[1] | ||
const filename = report.split('\n')[1]; | ||
|
||
assert(filename === path.join(__dirname, 'style.css'), 'filename is correct') | ||
assert(report.match(/char 3/), 'report contains text') | ||
assert(report.match(/Use of !important/), 'report contains text') | ||
assert(report.match(/1 warning/), 'report contains text') | ||
}) | ||
assert(filename === path.join(__dirname, 'style.css'), 'filename is correct'); | ||
assert(report.match(/char 3/), 'report contains text'); | ||
assert(report.match(/Use of !important/), 'report contains text'); | ||
assert(report.match(/1 warning/), 'report contains text'); | ||
}); | ||
|
||
it('should be able to be registered as formatter', () => { | ||
assert(!CSSLint.hasFormat('stylish'), 'csslint should not be stylish') | ||
assert(!CSSLint.hasFormat('stylish'), 'csslint should not be stylish'); | ||
|
||
CSSLint.addFormatter(reporter) | ||
CSSLint.addFormatter(reporter); | ||
|
||
assert(CSSLint.hasFormat('stylish'), 'csslint should be stylish') | ||
}) | ||
assert(CSSLint.hasFormat('stylish'), 'csslint should be stylish'); | ||
}); | ||
|
||
it('should not report undefined output lines when no filename provided', () => { | ||
const res = CSSLint.verify('.class {\n color: red !important\n}\n') | ||
const res = CSSLint.verify('.class {\n color: red !important\n}\n'); | ||
|
||
let report = reporter.startFormat() + reporter.formatResults(res) + reporter.endFormat() | ||
let report = reporter.startFormat() + reporter.formatResults(res) + reporter.endFormat(); | ||
|
||
report = chalk.stripColor(report) | ||
report = chalk.stripColor(report); | ||
|
||
let matches = report.match(/^undefined$/gm) | ||
const matches = report.match(/^undefined$/gm); | ||
|
||
assert(matches === null, 'report should not contains undefined text output') | ||
}) | ||
assert(matches === null, 'report should not contains undefined text output'); | ||
}); | ||
|
||
it('should report filename provided', () => { | ||
const res = CSSLint.verify('.class {\n color: red !important\n}\n') | ||
const filename = path.resolve('filenamestyle.css') | ||
const res = CSSLint.verify('.class {\n color: red !important\n}\n'); | ||
const filename = path.resolve('filenamestyle.css'); | ||
let report = reporter.startFormat() + reporter.formatResults(res, filename, | ||
{ absoluteFilePathsForFormatters: true }) + reporter.endFormat() | ||
{ absoluteFilePathsForFormatters: true }) + reporter.endFormat(); | ||
|
||
report = chalk.stripColor(report) | ||
report = chalk.stripColor(report); | ||
|
||
const matches = report.match(/^undefined$/gm) | ||
const outfilename = report.split('\n')[1] | ||
const matches = report.match(/^undefined$/gm); | ||
const outfilename = report.split('\n')[1]; | ||
|
||
assert(matches === null, 'report should not contains undefined text output') | ||
assert(outfilename === filename, 'filename should be in output lines') | ||
}) | ||
}) | ||
assert(matches === null, 'report should not contains undefined text output'); | ||
assert(outfilename === filename, 'filename should be in output lines'); | ||
}); | ||
}); |