Skip to content

Commit

Permalink
Add tests for valid SCSS (#341)
Browse files Browse the repository at this point in the history
* Add test for valid color-hex-case

* Add tests for valid color-hex-length

* Add additional valid SCSS tests

* Update valid test cases

* Remove white space from valid SCSS test cases
  • Loading branch information
bjankord authored Jul 11, 2024
1 parent c00cb4e commit caabdb9
Show file tree
Hide file tree
Showing 32 changed files with 923 additions and 356 deletions.
25 changes: 25 additions & 0 deletions __tests__/block-opening-brace-space-before.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,28 @@ describe('flags warnings with block-opening-brace-space-before lint', () => {
);
});
});

describe('does not flag warnings with valid block-opening-brace-space-before', () => {
const validScss = (
`.test-selector {
color: #fff;
}
`);

let result;

beforeEach(async () => {
result = await stylelint.lint({
code: validScss,
config,
});
});

it('did not error', () => {
assert.equal(result.errored, false);
});

it('does not flag warnings', () => {
assert.equal(result.results[0].warnings.length, 0);
});
});
25 changes: 25 additions & 0 deletions __tests__/color-hex-case.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,28 @@ describe('flags warnings with color-hex-case lint', () => {
);
});
});

describe('does not flag warnings with valid color-hex-case', () => {
const validScss = (
`.test-selector {
color: #fff;
}
`);

let result;

beforeEach(async () => {
result = await stylelint.lint({
code: validScss,
config,
});
});

it('did not error', () => {
assert.equal(result.errored, false);
});

it('does not flag warnings', () => {
assert.equal(result.results[0].warnings.length, 0);
});
});
25 changes: 25 additions & 0 deletions __tests__/color-hex-length.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,28 @@ describe('flags warnings with color-hex-length lint', () => {
);
});
});

describe('does not flag warnings with valid color-hex-length', () => {
const validScss = (
`.test-selector {
color: #fff;
}
`);

let result;

beforeEach(async () => {
result = await stylelint.lint({
code: validScss,
config,
});
});

it('did not error', () => {
assert.equal(result.errored, false);
});

it('does not flag warnings', () => {
assert.equal(result.results[0].warnings.length, 0);
});
});
25 changes: 25 additions & 0 deletions __tests__/declaration-bang-space-after.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,28 @@ describe('flags warnings with declaration-bang-space-after lint', () => {
);
});
});

describe('does not flag warnings with valid declaration-bang-space-after', () => {
const validScss = (
`.test-selector {
color: #000 !important;
}
`);

let result;

beforeEach(async () => {
result = await stylelint.lint({
code: validScss,
config,
});
});

it('did not error', () => {
assert.equal(result.errored, false);
});

it('does not flag warnings', () => {
assert.equal(result.results[0].warnings.length, 0);
});
});
25 changes: 25 additions & 0 deletions __tests__/declaration-bang-space-before.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,28 @@ describe('flags warnings with declaration-bang-space-before lint', () => {
);
});
});

describe('does not flag warnings with valid declaration-bang-space-before', () => {
const validScss = (
`.test-selector {
color: #000 !important;
}
`);

let result;

beforeEach(async () => {
result = await stylelint.lint({
code: validScss,
config,
});
});

it('did not error', () => {
assert.equal(result.errored, false);
});

it('does not flag warnings', () => {
assert.equal(result.results[0].warnings.length, 0);
});
});
27 changes: 27 additions & 0 deletions __tests__/declaration-block-semicolon-newline-after.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,30 @@ describe('flags warnings with declaration-block-semicolon-newline-after lint', (
);
});
});

describe('does not flag warnings with valid declaration-block-semicolon-newline-after', () => {
const validScss = (
`.test-selector {
color: #fff;
border: 0;
}
`);

let result;

beforeEach(async () => {
result = await stylelint.lint({
code: validScss,
config,
});
});

it('did not error', () => {
assert.equal(result.errored, false);
});

it('does not flag warnings', () => {
assert.equal(result.results[0].warnings.length, 0);
});
});
23 changes: 23 additions & 0 deletions __tests__/declaration-block-single-line-max-declarations.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,26 @@ describe('flags warnings with declaration-block-single-line-max-declarations lin
);
});
});

describe('does not flag warnings with valid declaration-block-single-line-max-declarations', () => {
const validScss = (
`.test-selector { color: #000; }
`);

let result;

beforeEach(async () => {
result = await stylelint.lint({
code: validScss,
config,
});
});

it('did not error', () => {
assert.equal(result.errored, false);
});

it('does not flag warnings', () => {
assert.equal(result.results[0].warnings.length, 0);
});
});
23 changes: 23 additions & 0 deletions __tests__/declaration-colon-space-after.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,26 @@ describe('flags warnings with declaration-colon-space-after lint', () => {
);
});
});

describe('does not flag warnings with valid declaration-colon-space-after', () => {
const validScss = (
`.test-selector { color: #fff; }
`);

let result;

beforeEach(async () => {
result = await stylelint.lint({
code: validScss,
config,
});
});

it('did not error', () => {
assert.equal(result.errored, false);
});

it('does not flag warnings', () => {
assert.equal(result.results[0].warnings.length, 0);
});
});
23 changes: 23 additions & 0 deletions __tests__/declaration-colon-space-before.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,26 @@ describe('flags warnings with declaration-colon-space-before lint', () => {
);
});
});

describe('does not flag warnings with valid declaration-colon-space-before', () => {
const validScss = (
`.test-selector { color: #fff; }
`);

let result;

beforeEach(async () => {
result = await stylelint.lint({
code: validScss,
config,
});
});

it('did not error', () => {
assert.equal(result.errored, false);
});

it('does not flag warnings', () => {
assert.equal(result.results[0].warnings.length, 0);
});
});
26 changes: 26 additions & 0 deletions __tests__/function-comma-space-after.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,29 @@ describe('flags warnings with function-comma-space-after lint', () => {
);
});
});

describe('does not flag warnings with valid function-comma-space-after', () => {
const validScss = (
`.test-selector {
@include box-shadow(0 2px 2px rgba(0, 0, 0, 0.2));
color: rgba(0, 0, 0, 0.1);
}
`);

let result;

beforeEach(async () => {
result = await stylelint.lint({
code: validScss,
config,
});
});

it('did not error', () => {
assert.equal(result.errored, false);
});

it('does not flag warnings', () => {
assert.equal(result.results[0].warnings.length, 0);
});
});
26 changes: 26 additions & 0 deletions __tests__/function-parentheses-space-inside.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,29 @@ describe('flags warnings with function-parentheses-space-inside lint', () => {
);
});
});

describe('does not flag warnings with valid function-parentheses-space-inside', () => {
const validScss = (
`.test-selector {
@include box-shadow(0 2px 2px rgba(0, 0, 0, 0.2));
color: rgba(0, 0, 0, 0.1);
}
`);

let result;

beforeEach(async () => {
result = await stylelint.lint({
code: validScss,
config,
});
});

it('did not error', () => {
assert.equal(result.errored, false);
});

it('does not flag warnings', () => {
assert.equal(result.results[0].warnings.length, 0);
});
});
26 changes: 26 additions & 0 deletions __tests__/function-url-quotes.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,29 @@ describe('flags warnings with function-url-quotes lint', () => {
);
});
});

describe('does not flag warnings with valid function-url-quotes', () => {
const validScss = (
`.test-selector {
background: url('example.png');
}
`);

let result;

beforeEach(async () => {
result = await stylelint.lint({
code: validScss,
config,
});
});

it('did not error', () => {
assert.equal(result.errored, false);
});

it('does not flag warnings', () => {
assert.equal(result.results[0].warnings.length, 0);
});
});
25 changes: 25 additions & 0 deletions __tests__/indentation.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,28 @@ color: #fff;
);
});
});

describe('does not flag warnings with valid indentation', () => {
const validScss = (
`.test-selector {
color: #000;
}
`);

let result;

beforeEach(async () => {
result = await stylelint.lint({
code: validScss,
config,
});
});

it('did not error', () => {
assert.equal(result.errored, false);
});

it('does not flag warnings', () => {
assert.equal(result.results[0].warnings.length, 0);
});
});
Loading

0 comments on commit caabdb9

Please sign in to comment.