mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 10:25:02 +08:00
fe588cc7f8
* DEV: Fix the function prototype observers deprecation DEPRECATION: Function prototype extensions have been deprecated, please migrate from function(){}.observes('foo') to observer('foo', function() {}). [deprecation id: function-prototype-extensions.observes] See https://deprecations.emberjs.com/v3.x/#toc_function-prototype-extensions-observes for more details. * DEV: Fix the function prototype event listeners deprecation DEPRECATION: Function prototype extensions have been deprecated, please migrate from function(){}.on('foo') to on('foo', function() {}). [deprecation id: function-prototype-extensions.on] See https://deprecations.emberjs.com/v3.x/#toc_function-prototype-extensions-on for more details. * DEV: Simplify `default as` imports Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
27 lines
544 B
JavaScript
27 lines
544 B
JavaScript
import highlightText, { CLASS_NAME } from "discourse/lib/highlight-text";
|
|
import { fixture } from "helpers/qunit-helpers";
|
|
|
|
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"
|
|
);
|
|
});
|