Skip to content

Commit

Permalink
Migrate test/e2e/__tests__/lint.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
ybiquitous committed Aug 26, 2024
1 parent 50ef3f6 commit 282e71d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
1 change: 1 addition & 0 deletions .vscode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if (!minimumVscodeVersion) throw new Error(`"engines.vscode" is unexpected: ${pk
module.exports = defineConfig({
// TODO: files: ['test/e2e/__tests__/**/*.ts'],
files: [
'test/e2e/__tests__/lint.ts',
'test/e2e/__tests__/report-descriptionless-disables.ts',
'test/e2e/__tests__/report-invalid-scope-disables.ts',
'test/e2e/__tests__/report-needless-disables.ts',
Expand Down
44 changes: 38 additions & 6 deletions test/e2e/__tests__/lint.ts
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 () => {

Check warning on line 8 in test/e2e/__tests__/lint.ts

View workflow job for this annotation

GitHub Actions / lint / Lint on Node.js lts/* and ubuntu-latest

Test has no assertions
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 () => {

Check warning on line 23 in test/e2e/__tests__/lint.ts

View workflow job for this annotation

GitHub Actions / lint / Lint on Node.js lts/* and ubuntu-latest

Test has no assertions
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',
},
]);
});
});

0 comments on commit 282e71d

Please sign in to comment.