-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
50ef3f6
commit 282e71d
Showing
2 changed files
with
39 additions
and
6 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 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,18 +1,50 @@ | ||
import path from 'path'; | ||
import { normalizeDiagnostic } from '../utils'; | ||
import { openDocument, waitForDiagnostics, assertDiagnostics, closeAllEditors } from '../helpers'; | ||
|
||
describe('Linting', () => { | ||
afterEach(async () => { | ||
await closeAllEditors(); | ||
}); | ||
|
||
it('should lint CSS documents', async () => { | ||
const { document } = await openDocument(path.resolve(workspaceDir, 'defaults/lint.css')); | ||
const document = await openDocument('defaults/lint.css'); | ||
const diagnostics = await waitForDiagnostics(document); | ||
|
||
expect(diagnostics.map(normalizeDiagnostic)).toMatchSnapshot(); | ||
assertDiagnostics(diagnostics, [ | ||
{ | ||
code: 'indentation', | ||
codeDescription: 'https://stylelint.io/user-guide/rules/indentation', | ||
message: 'Expected indentation of 4 spaces (indentation)', | ||
range: [2, 2, 2, 13], | ||
severity: 'error', | ||
}, | ||
]); | ||
}); | ||
|
||
it('should display rule documentation links when one is available', async () => { | ||
const { document } = await openDocument(path.resolve(workspaceDir, 'defaults/rule-doc.css')); | ||
const document = await openDocument('defaults/rule-doc.css'); | ||
const diagnostics = await waitForDiagnostics(document); | ||
|
||
expect(diagnostics.map(normalizeDiagnostic)).toMatchSnapshot(); | ||
assertDiagnostics(diagnostics, [ | ||
{ | ||
code: 'plugin/foo-bar', | ||
message: 'Bar (plugin/foo-bar)', | ||
range: [0, 5, 0, 6], | ||
severity: 'error', | ||
}, | ||
{ | ||
code: 'color-no-invalid-hex', | ||
codeDescription: 'https://stylelint.io/user-guide/rules/color-no-invalid-hex', | ||
message: 'Unexpected invalid hex color "#y3" (color-no-invalid-hex)', | ||
range: [6, 11, 6, 14], | ||
severity: 'error', | ||
}, | ||
{ | ||
code: 'indentation', | ||
codeDescription: 'https://stylelint.io/user-guide/rules/indentation', | ||
message: 'Expected indentation of 4 spaces (indentation)', | ||
range: [2, 2, 2, 13], | ||
severity: 'error', | ||
}, | ||
]); | ||
}); | ||
}); |