import { module, test } from "qunit";
import { cookAsync, excerpt } from "discourse/lib/text";
module("Unit | Utility | text", function () {
test("excerpt", async function (assert) {
let cooked = await cookAsync("Hello! :wave:");
assert.strictEqual(
await excerpt(cooked, 300),
'Hello!
'
);
cooked = await cookAsync("[:wave:](https://example.com)");
assert.strictEqual(
await excerpt(cooked, 300),
'
'
);
cooked = await cookAsync('');
assert.strictEqual(await excerpt(cooked, 300), "");
cooked = await cookAsync("[``]()");
assert.strictEqual(
await excerpt(cooked, 300),
"<script>alert('hi')</script>"
);
});
});