if the element only contains
, when reading it with shallowWrapper.text(), it doesn't equal to ' ' (one space)
should equal to ' ' (one space)
| library | version
| ---------------- | -------
| Enzyme | 3.3.0
| React | 16.3.0
// component
const Foo = () => (
<div className={styles.foo}>
</div>
);
// test
const container = shallow(<Foo />);
expect(container.find(`.${styles.foo}`).text()).toEqual(' ');
// test result
expect(received).toEqual(expected)
Expected value to equal:
" "
Received:
" "
related to #1349 ?
For now this works
expect(container.find(`.${styles.foo}`).text()).toEqual('\u00a0');
Basically nbsps translate to this unix code \u00a0
I think the issue is that perhaps your literal non-breaking space in your tests is getting transformed to a normal one.
I've added explicit tests for the character codes generated by non-breaking spaces, and they both are already passing.
Most helpful comment
For now this works
Basically nbsps translate to this unix code
\u00a0