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

This whitespace replace regex is not replacing   encoded whitespaces. #1592

Open
ChristianGreinke opened this issue May 31, 2022 · 3 comments

Comments

@ChristianGreinke
Copy link

This whitespace replace regex is not replacing   encoded whitespaces.

https://github.com/simplabs/qunit-dom/blob/ec5c614f1ea589419eea1591f9b62d32760dc5a1/lib/helpers/collapse-whitespace.ts#L4

You could maybe replace with
.replace(/[ \u00a0]+/g, ' ')

It creates for example issues with assert.dom().hasText() where one uses test text to compare with dom element textContent and all multiple continuous white spaces from the test text are collapsed to one single white space.

For example with html

a   b


assert.dom('p').hasText('a b') would fail
and it is not possible to create a hasText parameter which would succeed the assertion.

@Turbo87
Copy link
Collaborator

Turbo87 commented May 31, 2022

assert.dom('p').hasText('a b') would fail

that is intentional because multiple nbsp are not collapsed into a single whitespace.

@ChristianGreinke
Copy link
Author

that is intentional because multiple nbsp are not collapsed into a single whitespace.

I see. That means assert..hasText is not usable for dom text elements having   encodings. Is there an alternative one could use? Besides not using   at all. Though then you get collapsed whitespace in the rendered browser output. Which could only be prevented by adding more boilerplate styles like white-space : pre.

@Turbo87
Copy link
Collaborator

Turbo87 commented Jun 2, 2022

hasText() supports regex expectations. maybe that helps?

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

No branches or pull requests

2 participants