-
-
Notifications
You must be signed in to change notification settings - Fork 254
Add tests for BitCollapase component (#11608) #11609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for BitCollapase component (#11608) #11609
Conversation
WalkthroughA new unit test file for the BitCollapse Blazor component is introduced using MSTest and BUnit. Tests cover child content rendering, expanded state CSS class toggles, and custom styling via BitCollapseClassStyles configuration. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/BlazorUI/Bit.BlazorUI.Tests/Components/Surfaces/Collapse/BitCollapseTests.cs (1)
47-71: Consider testing the Expanded=false case for custom styles.The test verifies that custom classes and styles are applied when
Expanded=true, but doesn't test that the Expanded-specific class and style are NOT applied whenExpanded=false. Adding a test case forExpanded=falsewould improve coverage and ensure the component correctly applies conditional styling.Consider adding:
[TestMethod] public void BitCollapseShouldNotApplyExpandedStylesWhenCollapsed() { var classes = new BitCollapseClassStyles { Root = "root-class", Content = "content-class", Expanded = "expanded-class" }; var styles = new BitCollapseClassStyles { Root = "width:1px", Content = "width:2px", Expanded = "width:3px" }; var component = RenderComponent<BitCollapse>(parameters => { parameters.Add(p => p.Classes, classes); parameters.Add(p => p.Styles, styles); parameters.Add(p => p.Expanded, false); parameters.AddChildContent("<div>content</div>"); }); var root = component.Find(".bit-col"); Assert.IsTrue(root.ClassList.Contains("root-class")); Assert.IsFalse(root.ClassList.Contains("expanded-class")); Assert.IsTrue(root.GetAttribute("style")?.Contains("width:1px") ?? false); Assert.IsFalse(root.GetAttribute("style")?.Contains("width:3px") ?? false); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (1)
src/BlazorUI/Bit.BlazorUI.Tests/Components/Surfaces/Collapse/BitCollapseTests.cs(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build and test
🔇 Additional comments (3)
src/BlazorUI/Bit.BlazorUI.Tests/Components/Surfaces/Collapse/BitCollapseTests.cs (3)
9-20: LGTM! Child content rendering test is well-structured.The test correctly verifies that child content is rendered within the BitCollapse component and that the root element is present.
22-45: LGTM! Expanded state test is comprehensive.Good use of
DataTestMethodto cover both expanded and collapsed states. The CSS class assertions correctly verify the component's state-based styling.
68-70: Verify conflicting width styles on the root element.Lines 68 and 70 both assert that the root element's style attribute contains different width values ("width:1px" from Root and "width:3px" from Expanded). When both are present in the style attribute, only one width value can take effect in CSS (typically the last one).
Please verify this is the intended behavior and that the component correctly combines these styles in the style attribute string.
closes #11608
Summary by CodeRabbit