Skip to content

Commit

Permalink
test: Updated test for custom properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaetan Flament committed Dec 5, 2023
1 parent 8a8cfaf commit ac52556
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"lint": "xo",
"fix": "xo --fix",
"test": "npm-run-all --aggregate-output --continue-on-error --parallel --parallel test:*",
"test:cli": "node ./bin/cli.js tests/ --ignore=\"$a,$b\" --ignoreFiles=\"**/ignored-file*.scss\"",
"test:cli": "node ./bin/cli.js tests/ --ignore=\"$a,$b,--a,--b\" --ignoreFiles=\"**/ignored-file*.scss\"",
"test:integration": "node tests/integration.js",
"test:options": "node tests/options.js",
"test-ci": "npm-run-all --aggregate-output --continue-on-error --parallel test:integration test:options"
Expand Down
12 changes: 12 additions & 0 deletions tests/fixtures/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ $disabled-variable: #bada55;
// fusv-enable

$enabled-variable: #b000b5;

:root {
--a: 10px;
--b: 20px;
--black-light: #{$black-light};
--black-lightest: #{$black-lightest};
--ignored-variable: #ace;
// fusv-disable
--disabled-variable: #bada55;
// fusv-enable
--enabled-variable: #101;
}
3 changes: 3 additions & 0 deletions tests/fixtures/ignored-file.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
// unused but ignored file variables
$unused-but-ignored : #000;
:root {
--unused-but-ignored: #000;
}
8 changes: 8 additions & 0 deletions tests/fixtures/test.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,11 @@
.black-lightest {
background-color: $black-lightest;
}

.modal-black-light {
background-color: var(--black-light);
}

.modal-black-lightest {
background-color: var(--black-lightest);
}
7 changes: 5 additions & 2 deletions tests/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ const expectedUnused = [
'$black',
'$nestedVar',
'$nestNestedVar',
'$enabled-variable'
'$enabled-variable',
'--a',
'--b',
'--enabled-variable',

Check failure on line 15 in tests/integration.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected trailing comma.
];
const ignore = ['$ignored-variable'];
const ignore = ['$ignored-variable', '--ignored-variable'];
const ignoreFiles = ['**/ignored-file*.scss'];

const runTests = (type, result) => {
Expand Down
13 changes: 10 additions & 3 deletions tests/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,23 @@ const allExpectedUnused = [
'$nestedVar',
'$nestNestedVar',
'$enabled-variable',
'$ignored-variable'
'$ignored-variable',
'--a',
'--b',
'--ignored-variable',
'--enabled-variable',

Check failure on line 18 in tests/options.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected trailing comma.
];
const expectedUnused = [
'$unused',
'$black',
'$nestedVar',
'$nestNestedVar',
'$enabled-variable'
'$enabled-variable',
'--a',
'--b',
'--enabled-variable',

Check failure on line 28 in tests/options.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected trailing comma.
];
const ignore = ['$ignored-variable', '$a', '$b'];
const ignore = ['$ignored-variable', '$a', '$b', '--ignored-variable'];
const ignoreFiles = ['**/ignored-file*.scss'];

console.log('Running "Options" tests...');
Expand Down

0 comments on commit ac52556

Please sign in to comment.