2019-03-26 05:52:06 -04:00
|
|
|
import {
|
|
|
|
default as highlightText,
|
|
|
|
CLASS_NAME
|
|
|
|
} from "discourse/lib/highlight-text";
|
2019-06-06 07:10:41 -04:00
|
|
|
import { fixture } from "helpers/qunit-helpers";
|
2019-03-26 05:52:06 -04:00
|
|
|
|
|
|
|
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"
|
|
|
|
);
|
|
|
|
});
|