From ec1253f9c9b3a54fedda0ece4c6ca6f451a01c95 Mon Sep 17 00:00:00 2001 From: Frank Wang Date: Thu, 28 Sep 2023 22:17:01 +0000 Subject: [PATCH] Add animation name test case --- test/files/animationName.scss | 14 ++++++++++++++ test/lib/rules/no-undef-class.test.js | 26 ++++++++++++++++++++++++++ test/lib/rules/no-unused-class.test.js | 26 ++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 test/files/animationName.scss diff --git a/test/files/animationName.scss b/test/files/animationName.scss new file mode 100644 index 0000000..f13bc75 --- /dev/null +++ b/test/files/animationName.scss @@ -0,0 +1,14 @@ +// Used in `className` +@keyframes animationName1 {} + +// Used in other classes +@keyframes animationName2 {} + +.classUsingAnimation { + animation-name: animationName2; +} + +// Using undefined animation name in another class +.classUsingAnimation { + animation-name: undefinedAnimationName; +} \ No newline at end of file diff --git a/test/lib/rules/no-undef-class.test.js b/test/lib/rules/no-undef-class.test.js index 816d641..8f502d1 100644 --- a/test/lib/rules/no-undef-class.test.js +++ b/test/lib/rules/no-undef-class.test.js @@ -566,4 +566,30 @@ describe('no-undef-class', function () { }, ].map((testCase) => addFilenameOption(testCase)), }); + + ruleTester.run('no-undef-class', rule, { + valid: [], + invalid: [ + { + name: 'should support animation identifiers - using undefined in className', + code: ` + import s from 'test/files/animationName.scss'; + + export default Foo = () => ( +
+ ); + `, + }, + { + name: 'should support animation identifiers - using undefined in another class', + code: ` + import s from 'test/files/animationName.scss'; + + export default Foo = () => ( +
+ ); + `, + }, + ].map((testCase) => addFilenameOption(testCase)), + }); }); diff --git a/test/lib/rules/no-unused-class.test.js b/test/lib/rules/no-unused-class.test.js index 1fc938f..bef9d8e 100644 --- a/test/lib/rules/no-unused-class.test.js +++ b/test/lib/rules/no-unused-class.test.js @@ -359,4 +359,30 @@ describe('no-unused-class', function () { }, ].map((testCase) => addFilenameOption(testCase)), }); + + ruleTester.run('no-unused-class', rule, { + valid: [ + { + name: 'should support animation identifiers - used in another class', + code: ` + import s from 'test/files/animationName.scss'; + + export default Foo = () => ( +
+ ); + `, + }, + { + name: 'should support animation identifiers - used in className', + code: ` + import s from 'test/files/animationName.scss'; + + export default Foo = () => ( +
+ ); + `, + }, + ].map((testCase) => addFilenameOption(testCase)), + invalid: [], + }); });