| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Add tests for `getEdgeStyle` and `getPerimeterFunction`.
WalkthroughA new test suite has been introduced for the GraphView component, focusing on the getEdgeStyle and getPerimeterFunction methods. The tests cover various scenarios, including different configurations of edge styles and perimeter functions, the presence or absence of registry entries, and the direct use of function references. The suite uses Jest for test structure and assertions, and includes setup and teardown logic to ensure test isolation by clearing relevant registries before and after tests. Changes
Sequence Diagram(s)sequenceDiagram
participant TestSuite
participant GraphView
participant StyleRegistry
participant PerimeterRegistry
TestSuite->>GraphView: getEdgeStyle(cellState, ...args)
alt isLoopStyleEnabled returns true
GraphView-->>TestSuite: Return loop style (default or from cell state)
else isLoopStyleEnabled returns false
alt style is string and in StyleRegistry
GraphView->>StyleRegistry: get(styleKey)
StyleRegistry-->>GraphView: styleFunction
GraphView-->>TestSuite: Return styleFunction
else style is function
GraphView-->>TestSuite: Return style function directly
else
GraphView-->>TestSuite: Return null
end
end
TestSuite->>GraphView: getPerimeterFunction(cellState)
alt perimeter is string and in PerimeterRegistry
GraphView->>PerimeterRegistry: get(perimeterKey)
PerimeterRegistry-->>GraphView: perimeterFunction
GraphView-->>TestSuite: Return perimeterFunction
else perimeter is function
GraphView-->>TestSuite: Return perimeter function directly
else
GraphView-->>TestSuite: Return null
end
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. ❤️ Share 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (.coderabbit.yaml)
Documentation and Community
|
Sorry, something went wrong.
|
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)packages/core/__tests__/view/GraphView.test.ts (1)📜 Review details1-154: Consider adding tests for potential edge cases.
While the current tests provide excellent coverage of normal usage patterns, consider adding tests for edge cases such as:
- What happens when an invalid value type is provided for edge style or perimeter?
- What happens with empty string values?
- Are there any performance considerations with registry lookups that should be tested?
These additional tests would strengthen the test suite and help prepare for the future refactoring mentioned in the PR objectives.
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Reviewing files that changed from the base of the PR and between e87f5ea and 1485532.
📒 Files selected for processing (1)packages/core/src/view/style/register.ts (1)⏰ Context from checks skipped due to timeout of 90000ms (4)
- unregisterAllEdgeStylesAndPerimeters (94-98)
packages/core/__tests__/view/GraphView.test.ts (7)1-27: Proper setup with comprehensive imports and license header.
The test file correctly includes the necessary imports for testing and the required components from the source code. The Apache 2.0 license header is appropriately included.
28-53: Well-structured tests for getEdgeStyle with isLoopStyleEnabled returning true.
The tests effectively cover both scenarios: default loop style behavior and custom loop style from cell state. Using a subclass to control isLoopStyleEnabled is a clean approach for this specific use case.
55-62: Good test isolation practices.
Using beforeEach and afterAll hooks with unregisterAllEdgeStylesAndPerimeters() ensures proper test isolation by cleaning up the registry before each test and after all tests are complete, preventing side effects between test cases.
64-73: Clear approach for controlling test conditions.
The comment explains the rationale for using a manual double instead of Jest mocks, which is appropriate for this simple case. The helper function for creating graphs with the test double improves code readability.
74-114: Comprehensive test coverage for getEdgeStyle with isLoopStyleEnabled returning false.
These tests cover all key scenarios:
- No edge style in cell state
- String edge style with no registry match
- String edge style with registry match
- Edge style with noEdgeStyle flag
- Function edge style directly
Each test verifies a specific behavior of the method, providing excellent coverage.
117-124: Good test isolation for perimeter function tests.
Similar to the edge style tests, proper test isolation is ensured by using beforeEach and afterAll hooks with unregisterAllEdgeStylesAndPerimeters().
126-153: Thorough test coverage for getPerimeterFunction.
These tests effectively cover all key scenarios for the perimeter function:
- No perimeter specified
- String perimeter with no registry match
- String perimeter with registry match
- Function perimeter directly
The tests are clear, concise, and verify the expected behavior for each scenario.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Add tests for getEdgeStyle and getPerimeterFunction.
This change prepares refactoring that will be later done on this 2 methods.
Notes
Covers #758
Covers #767
Summary by CodeRabbit