|
|
|
@ -6,14 +6,14 @@ export default test({
|
|
|
|
|
<div> hello hello</div>`,
|
|
|
|
|
|
|
|
|
|
test({ assert, target }) {
|
|
|
|
|
const divList = target.querySelectorAll('div');
|
|
|
|
|
assert.equal(divList[0].textContent?.charCodeAt(0), 160);
|
|
|
|
|
assert.equal(divList[1].textContent?.charCodeAt(0), 160);
|
|
|
|
|
assert.equal(divList[1].textContent?.charCodeAt(6), 160);
|
|
|
|
|
assert.equal(divList[1].textContent?.charCodeAt(7), 160);
|
|
|
|
|
assert.equal(divList[2].textContent?.charCodeAt(0), 160);
|
|
|
|
|
assert.equal(divList[2].textContent?.charCodeAt(6), 160);
|
|
|
|
|
assert.equal(divList[2].textContent?.charCodeAt(7), 32); //normal space
|
|
|
|
|
assert.equal(divList[2].textContent?.charCodeAt(8), 160);
|
|
|
|
|
const div_list = target.querySelectorAll('div');
|
|
|
|
|
assert.equal(normalizeSpaces(div_list[0].textContent), ' hello');
|
|
|
|
|
assert.equal(normalizeSpaces(div_list[1].textContent), ' hello ');
|
|
|
|
|
assert.equal(normalizeSpaces(div_list[2].textContent), ' hello hello');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
/** @param {string | null} str */
|
|
|
|
|
function normalizeSpaces(str) {
|
|
|
|
|
return str ? str.replaceAll(String.fromCharCode(160), ' ') : str;
|
|
|
|
|
}
|
|
|
|
|