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
1 changed file
with
53 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const config = require("../") | ||
const stylelint = require("stylelint") | ||
const test = require("ava") | ||
|
||
const validCss = | ||
`.selector-x { width: 10%; } | ||
.selector-y { width: 20%; } | ||
.selector-z { width: 30%; } | ||
` | ||
|
||
const invalidCss = | ||
`a { | ||
top: .2em; | ||
} | ||
` | ||
|
||
test("stylelint runs with config", t => { | ||
return stylelint.lint({ | ||
code: "a { font-weight: bold; }", | ||
config: config | ||
}) | ||
.then(data => { | ||
t.truthy(true, "config works") | ||
t.truthy(data, "data exists") | ||
}) | ||
}) | ||
|
||
test("no warnings with valid css", t => { | ||
return stylelint.lint({ | ||
code: validCss, | ||
config: config, | ||
}) | ||
.then(data => { | ||
const { errored, results } = data | ||
const { warnings } = results[0] | ||
t.falsy(errored, "no errored") | ||
t.is(warnings.length, 0, "flags no warnings") | ||
}) | ||
}) | ||
|
||
test("a warning with invalid css", t => { | ||
return stylelint.lint({ | ||
code: invalidCss, | ||
config: config, | ||
}) | ||
.then(data => { | ||
const { errored, results } = data | ||
const { warnings } = results[0] | ||
t.truthy(errored, "errored") | ||
t.is(warnings.length, 1, "flags one warning") | ||
t.is(warnings[0].text, "Expected a leading zero (number-leading-zero)", "correct warning text") | ||
}) | ||
}) |