-
Notifications
You must be signed in to change notification settings - Fork 19
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
1 parent
32a40e8
commit 0b553f9
Showing
5 changed files
with
951 additions
and
202 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
This file was deleted.
Oops, something went wrong.
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,68 @@ | ||
import { beforeEach, describe, it } from 'node:test'; | ||
import assert from 'node:assert/strict'; | ||
import { readFileSync } from 'node:fs'; | ||
|
||
import stylelint from 'stylelint'; | ||
|
||
import config from '../index.js'; | ||
|
||
const validScss = readFileSync('./__tests__/valid.scss', 'utf-8'); | ||
const invalidScss = readFileSync('./__tests__/invalid.scss', 'utf-8'); | ||
|
||
describe('flags no warnings with valid scss', () => { | ||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: validScss, | ||
config, | ||
}); | ||
}); | ||
|
||
it('did not error', () => { | ||
assert.equal(result.errored, false); | ||
}); | ||
|
||
it('flags no warnings', () => { | ||
assert.equal(result.results[0].warnings.length, 0); | ||
}); | ||
}); | ||
|
||
describe('flags warnings with invalid scss', () => { | ||
let result; | ||
|
||
beforeEach(async () => { | ||
result = await stylelint.lint({ | ||
code: invalidScss, | ||
config, | ||
}); | ||
}); | ||
|
||
it('did error', () => { | ||
assert.equal(result.errored, true); | ||
}); | ||
|
||
it('flags one warning', () => { | ||
assert.equal(result.results[0].warnings.length, 1); | ||
}); | ||
|
||
it('correct warning text', () => { | ||
assert.equal(result.results[0].warnings[0].text, 'Expected variable to be kebab-case'); | ||
}); | ||
|
||
it('correct rule flagged', () => { | ||
assert.equal(result.results[0].warnings[0].rule, 'scss/dollar-variable-pattern'); | ||
}); | ||
|
||
it('correct severity flagged', () => { | ||
assert.equal(result.results[0].warnings[0].severity, 'error'); | ||
}); | ||
|
||
it('correct line number', () => { | ||
assert.equal(result.results[0].warnings[0].line, 1); | ||
}); | ||
|
||
it('correct column number', () => { | ||
assert.equal(result.results[0].warnings[0].column, 1); | ||
}); | ||
}); |
Oops, something went wrong.