-
-
Notifications
You must be signed in to change notification settings - Fork 236
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
refactor: Make location info parser tests work #440
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BREAKING: The serialization of document types stored in the htmlparser2 adapter now no longer has an empty trailing string. Ie. `<!DOCTYPE html "">` is now `<!DOCTYPE html>`.
For some reason, we were escaping the data before. That meant we would only assert once that the received string matched the input. Now, we properly walk the tree (depth first, from the deepest node), and test nodes along the way. Requires #436
Otherwise this would be a breaking change
fb55
commented
Mar 7, 2022
|
||
assertNodeLocation(location, serializedNode, html, lines); | ||
|
||
// TODO: None of the cases below are ever matched. |
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.
This is the TODO that started this PR.
fb55
commented
Mar 7, 2022
@@ -113,42 +112,44 @@ export function generateLocationInfoParserTests( | |||
//Then for each node in the tree we run the serializer and compare results with the substring | |||
//obtained via the location info from the expected serialization results. | |||
it(`Location info (Parser) - ${test.name}`, async () => { | |||
const serializerOpts = { treeAdapter }; | |||
const html = escapeString(test.data); |
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.
This is the escapeString
call that invalidated the test.
fb55
changed the title
feat: Make location info parser tests work
refactor: Make location info parser tests work
Mar 7, 2022
wooorm
approved these changes
Mar 7, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I realised during the original refactor that
generateLocationInfoParserTests
didn't call some of the functions is was supposed to call. Digging into this now, it turned out that it was callingescapeString
on the input before processing anything. That meant we would receive a single long string with all of the document's content, and only assert a single time that the received string matched the input.Now, we properly walk the tree (depth first, from the deepest node), and test nodes along the way.
#436 was found during this effort.
Other changes necessary to make this work:
serializeOuter
was updated to serialise any kind of node.null
from document type functions (value was never used)SYSTEM
identifier to the data prop of document types of the htmlparser2 adapter. This was removed; ie.<!DOCTYPE html "">
is now<!DOCTYPE html>
.