mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 06:23:43 +08:00
e0cb2a434a
Add tests so it doesn't bite me again.
29 lines
510 B
JavaScript
29 lines
510 B
JavaScript
import {
|
|
default as highlightText,
|
|
CLASS_NAME
|
|
} from "discourse/lib/highlight-text";
|
|
|
|
QUnit.module("lib:highlight-text");
|
|
|
|
QUnit.test("highlighting text", assert => {
|
|
fixture().html(
|
|
`
|
|
<p>This is some text to highlight</p>
|
|
`
|
|
);
|
|
|
|
highlightText(fixture(), "some text");
|
|
|
|
const terms = [];
|
|
|
|
fixture(`.${CLASS_NAME}`).each((_, elem) => {
|
|
terms.push(elem.textContent);
|
|
});
|
|
|
|
assert.equal(
|
|
terms.join(" "),
|
|
"some text",
|
|
"it should highlight the terms correctly"
|
|
);
|
|
});
|