Skip to content
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

Export DOMException; remove custom assertions; etc. #174

Merged
merged 14 commits into from Jan 17, 2021

Conversation

karfau
Copy link
Member

@karfau karfau commented Jan 16, 2021

and the related vows test suite that was no longer run. (see #72 (comment))

This way the test output is no longer cluttered with all those warnings.
I also took care of converting var to const and let in the test files I touched.

@karfau karfau requested a review from brodybits January 16, 2021 14:48
@brodybits brodybits changed the title test: Stop using custom assertions Export DOMException; remove custom assertions; etc. Jan 17, 2021
"<xml xmlns:a='a' xmlns:b='b' xmlns='e'><child/></xml>",
'text/xml'
).documentElement
root.setAttributeNS('a', 'a:a', '1')
assert(root.attributes.length, 4)
expect(root.attributes.length).toEqual(4)
//not standart
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//not standart
//not standard

Comment on lines +7 to 8
const root = new DOMParser().parseFromString('<xml/>', 'text/xml')
.documentElement
Copy link
Member

@brodybits brodybits Jan 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have reformatted it ...

like this
Suggested change
const root = new DOMParser().parseFromString('<xml/>', 'text/xml')
.documentElement
const root = new DOMParser()
.parseFromString('<xml/>', 'text/xml')
.documentElement

but Prettier does not give us the option: prettier/prettier#7884 ... argh!

@brodybits
Copy link
Member

Thanks @karfau for your work on this. You should see that I have updated the title, please feel free to change it again if needed. I will likely push some updates and leave a few more suggestions.

Copy link
Member

@brodybits brodybits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if we can add DOMException to the documentation. I did push some updates which are mostly "nits". And a gentle reminder to merge this in a squash commit. Thanks again!

lib/dom.js Show resolved Hide resolved
Comment on lines 52 to 54
//not standart
// root.firstChild.setAttributeNode(root.attributes[0]);
// assert(root.attributes.length, 0);
// expect(root.attributes).toHaveLength(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be really awesome if we could understand why these commented-out lines are here and if there is anything we can do to resolve them. These commented-out lines seem to have come from this commit back in 2012: c9f94a8

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My first guess:
It's a test for something that is not specified in WC3 standard.
If it passes we should just activate and document it (in a different PR), since people might rely on it.
If it doesn't pass we should get rid of the comment :)

Will check it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though adding those lines leaves a passing test, it leaves the DOM in a broken state: the serialization of rootNode or rootNode.firstChild fails with Attribute in use.
Obviously it was not transferred to the new parent/owner correctly.

So I think we should just drop those lines. I don't think they hint to anything that is worth having a test for right now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would kept the comment, ideally with as much historical context as we know, until we get a chance to test the functionality. As I said in #72 (comment) this looks like untested functionality.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though adding those lines leaves a passing test, it leaves the DOM in a broken state

@karfau I missed that comment, guess you are right to remove it then. Hope we get a chance to test it someday:)

@karfau
Copy link
Member Author

karfau commented Jan 17, 2021

@brodybits We seem to using a mix of expect(...).toBe and expect(...).toEqual in our tests.
And it looks like you think we should use toBe when possible and only use toEqual for deep equality checks?

Should I also fix the other places of toEqual that compare literals? (In this PR or a separate one?)

@brodybits
Copy link
Member

And it looks like you think we should use toBe when possible and only use toEqual for deep equality checks?

toBe is preferred whenever possible (I think it is equivalent to ===); toStrictEqual when comparing objects for deep equality

Should I also fix the other places of toEqual that compare literals? (In this PR or a separate one?)

Yes. I think I would prefer fixing them in a separate PR.

@karfau karfau requested a review from brodybits January 17, 2021 21:23
@karfau
Copy link
Member Author

karfau commented Jan 17, 2021

I think I'm done with my changes in this PR. Can you have another look at the new changes?
Thx

@karfau karfau merged commit dbd2171 into xmldom:master Jan 17, 2021
@karfau karfau deleted the convert-assert-to-expect branch January 17, 2021 21:32
This was referenced Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants