Skip to content

Commit

Permalink
Add animation name test case
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhsianw committed Sep 28, 2023
1 parent 7e1931c commit ec1253f
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/files/animationName.scss
Original file line number Diff line number Diff line change
@@ -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;
}
26 changes: 26 additions & 0 deletions test/lib/rules/no-undef-class.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => (
<div className={s.undefinedAnimationName}></div>
);
`,
},
{
name: 'should support animation identifiers - using undefined in another class',
code: `
import s from 'test/files/animationName.scss';
export default Foo = () => (
<div></div>
);
`,
},
].map((testCase) => addFilenameOption(testCase)),
});
});
26 changes: 26 additions & 0 deletions test/lib/rules/no-unused-class.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => (
<div></div>
);
`,
},
{
name: 'should support animation identifiers - used in className',
code: `
import s from 'test/files/animationName.scss';
export default Foo = () => (
<div className={s.animationName1}></div>
);
`,
},
].map((testCase) => addFilenameOption(testCase)),
invalid: [],
});
});

0 comments on commit ec1253f

Please sign in to comment.