mirror of
https://github.com/discourse/discourse.git
synced 2025-03-28 15:05:42 +08:00

Using arrow functions changes `this` context, which is undesired in tests, e.g. it makes it impossible to setup things like pretender (`this.server`) in `beforeEach` hooks. Ember guides always use classic functions in examples (e.g. https://guides.emberjs.com/release/testing/test-types/), and that's what it uses in its own test suite, as do various addons and ember apps. It was also already used in Discourse where `this` was required. Moving forward, it will be needed in more places as we migrate toward ember-cli. (I might later add a custom rule to eslint-discourse-ember to enforce this)
32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
import { queryAll } from "discourse/tests/helpers/qunit-helpers";
|
|
import { click, fillIn, visit } from "@ember/test-helpers";
|
|
import { test } from "qunit";
|
|
import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
|
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
|
|
|
acceptance("Emoji", function (needs) {
|
|
needs.user();
|
|
|
|
test("emoji is cooked properly", async function (assert) {
|
|
await visit("/t/internationalization-localization/280");
|
|
await click("#topic-footer-buttons .btn.create");
|
|
|
|
await fillIn(".d-editor-input", "this is an emoji :blonde_woman:");
|
|
assert.equal(
|
|
queryAll(".d-editor-preview:visible").html().trim(),
|
|
`<p>this is an emoji <img src="/images/emoji/emoji_one/blonde_woman.png?v=${v}" title=":blonde_woman:" class="emoji" alt=":blonde_woman:"></p>`
|
|
);
|
|
});
|
|
|
|
test("skin toned emoji is cooked properly", async function (assert) {
|
|
await visit("/t/internationalization-localization/280");
|
|
await click("#topic-footer-buttons .btn.create");
|
|
|
|
await fillIn(".d-editor-input", "this is an emoji :blonde_woman:t5:");
|
|
assert.equal(
|
|
queryAll(".d-editor-preview:visible").html().trim(),
|
|
`<p>this is an emoji <img src="/images/emoji/emoji_one/blonde_woman/5.png?v=${v}" title=":blonde_woman:t5:" class="emoji" alt=":blonde_woman:t5:"></p>`
|
|
);
|
|
});
|
|
});
|