Skip to content

Commit 72b4efe

Browse files
Add test for PlainButton transient props filtering
- Add test case to verify that props starting with $ (transient props) are filtered out and not forwarded to the DOM - This exercises the else-branch of the if(!key.startsWith('$')) condition - Transient props are a styled-components convention for style-only props that should not appear as HTML attributes Addresses review comment from PR #2839 (Review #20) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent a1086d2 commit 72b4efe

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

src/app/components/Button.spec.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,29 @@ describe('PlainButton', () => {
356356
const tree = component.toJSON();
357357
expect(tree).toMatchSnapshot();
358358
});
359+
360+
it('filters out transient props (props starting with $)', () => {
361+
// Transient props (starting with $) should not be forwarded to the DOM
362+
// This is a styled-components convention for style-only props
363+
const component = renderer.create(
364+
<PlainButton
365+
{...({ $isActive: true } as any)}
366+
data-testid="test-button"
367+
>
368+
Click
369+
</PlainButton>
370+
);
371+
const tree = component.toJSON();
372+
373+
// Verify the button was rendered
374+
expect(tree).toBeTruthy();
375+
if (tree && typeof tree === 'object' && 'props' in tree) {
376+
// Verify standard props are present
377+
expect(tree.props['data-testid']).toBe('test-button');
378+
// Verify transient prop was filtered out
379+
expect(tree.props['$isActive']).toBeUndefined();
380+
}
381+
});
359382
});
360383

361384
describe('ButtonLink', () => {

0 commit comments

Comments
 (0)