-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[test]: add unit tests for xpath utils & tree format utils #1441
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
[test]: add unit tests for xpath utils & tree format utils #1441
Conversation
|
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.
No issues found across 2 files
| }); | ||
| }); | ||
|
|
||
| describe("diffCombinedTrees", () => { |
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.
non-crucial but could add a test for checking that the trimming works (i.e. if prevtree has different indentation vs nextree) since it's got a bunch of logic for that?
| }); | ||
| }); | ||
|
|
||
| describe("injectSubtrees", () => { |
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.
Could add a test for what happens when the same id appears twice, and if no ids found in the map I think?
|
|
||
| describe("prefixXPath", () => { | ||
| it("treats root prefixes as no-op", () => { | ||
| expect(prefixXPath("/", "/div[1]")).toBe("/div[1]"); |
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.
just fyi, you can use http://vitest.dev/api/#test-for this syntax in the future if you like it - is nice for parameterized testing - the syntax you currently have isn't too long so it doesn't matter, but it can be nice when there's more setup / LOC for each expect
why
what changed
tests/snapshot-xpath-utils.test.tsto cover all pure xpath helpers (prefixXPath(),normalizeXPath(),relativizeXPath(),buildChildXPathSegments(),joinXPath())tests/snapshot-tree-format-utils.test.tswhich tests formatting helpers (formatTreeLine(),injectSubtrees(),indentBlock(),diffCombinedTrees(),cleanText(),normaliseSpaces())test plan
Summary by cubic
Add unit tests for XPath utilities and tree formatting utilities to validate edge cases and prevent regressions. Tests cover path prefixing/normalization/joining, relative path derivation, positional selector building, subtree injection, diffing, indentation, and whitespace cleanup.
Written for commit df6ee84. Summary will update automatically on new commits.