UNPKG

@team23/stylelint-config-team23-scss

Version:

A set of stylelint rules used by TEAM23 for standard scss projects

57 lines 2.22 kB
import { __awaiter } from "tslib"; import { beforeEach, describe, expect, it } from 'vitest'; import config from '../index.js'; import fs from 'fs'; import stylelint from 'stylelint'; const validScss = fs.readFileSync('./src/tests/valid.scss', 'utf-8'); const invalidScss = fs.readFileSync('./src/tests/invalid.scss', 'utf-8'); const expectedErrorRules = [ 'scss/at-function-pattern', 'scss/at-mixin-pattern', 'scss/dollar-variable-pattern', 'scss/percent-placeholder-pattern', 'at-rule-empty-line-before', 'no-duplicate-selectors', ]; describe('flags no warnings with valid SCSS', () => { let result; beforeEach(() => { result = stylelint.lint({ code: validScss, config, }); }); it('did not error', () => __awaiter(void 0, void 0, void 0, function* () { return result.then(data => expect(data.errored).toBeFalsy()); })); it('flags no warnings', () => __awaiter(void 0, void 0, void 0, function* () { return result.then(data => expect(data.results[0].warnings).toHaveLength(0)); })); }); describe('flags warnings with invalid SCSS', () => { let result; beforeEach(() => { result = stylelint.lint({ code: invalidScss, config, }); }); it('should flag as errored', () => __awaiter(void 0, void 0, void 0, function* () { return result.then(data => { expect(data.errored).toBeTruthy(); }); })); it('should flag the correct number of errors', () => __awaiter(void 0, void 0, void 0, function* () { return result.then(data => { const expectedErrorCount = expectedErrorRules.length; const actualErrorCount = data.results[0].warnings.filter(w => w.severity === 'error').length; expect(actualErrorCount).toBe(expectedErrorCount); }); })); it.each(expectedErrorRules)('should contain error for rule: "%s"', (rule) => __awaiter(void 0, void 0, void 0, function* () { const _result = yield result; const rules = _result.results[0].warnings.map(warning => warning.rule); expect(rules).toContain(rule); })); }); //# sourceMappingURL=index.test.js.map