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)
28 lines
786 B
JavaScript
28 lines
786 B
JavaScript
import { test, module } from "qunit";
|
|
import {
|
|
iconHTML,
|
|
iconNode,
|
|
convertIconClass,
|
|
} from "discourse-common/lib/icon-library";
|
|
|
|
module("lib:icon-library");
|
|
|
|
test("return icon markup", function (assert) {
|
|
assert.ok(iconHTML("bars").indexOf('use xlink:href="#bars"') > -1);
|
|
|
|
const nodeIcon = iconNode("bars");
|
|
assert.equal(nodeIcon.tagName, "svg");
|
|
assert.equal(
|
|
nodeIcon.properties.attributes.class,
|
|
"fa d-icon d-icon-bars svg-icon svg-node"
|
|
);
|
|
});
|
|
|
|
test("convert icon names", function (assert) {
|
|
const fa5Icon = convertIconClass("fab fa-facebook");
|
|
assert.ok(iconHTML(fa5Icon).indexOf("fab-facebook") > -1, "FA 5 syntax");
|
|
|
|
const iconC = convertIconClass(" fab fa-facebook ");
|
|
assert.ok(iconHTML(iconC).indexOf(" ") === -1, "trims whitespace");
|
|
});
|