DEV: Remove undefined in Sidebar::SectionLink class attribute (#17881)
This commit is contained in:
parent
68cefc9f9d
commit
b653b86806
|
@ -9,7 +9,16 @@ export default class SectionLink extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
get classNames() {
|
get classNames() {
|
||||||
return `${this.args.class} sidebar-section-link sidebar-section-link-${this.args.linkName}`;
|
let classNames = [
|
||||||
|
"sidebar-section-link",
|
||||||
|
`sidebar-section-link-${this.args.linkName}`,
|
||||||
|
];
|
||||||
|
|
||||||
|
if (this.args.class) {
|
||||||
|
classNames.push(this.args.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
return classNames.join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
get models() {
|
get models() {
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
import { module, test } from "qunit";
|
||||||
|
|
||||||
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
|
import { render } from "@ember/test-helpers";
|
||||||
|
|
||||||
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||||
|
import { query } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
|
||||||
|
module("Integration | Component | sidebar | section-link", function (hooks) {
|
||||||
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
|
test("default class attribute for link", async function (assert) {
|
||||||
|
const template = hbs`<Sidebar::SectionLink @linkName="test" @route="discovery.latest" />`;
|
||||||
|
|
||||||
|
await render(template);
|
||||||
|
|
||||||
|
assert.strictEqual(
|
||||||
|
query("a").className,
|
||||||
|
"sidebar-section-link sidebar-section-link-test ember-view",
|
||||||
|
"has the right class attribute for the link"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("custom class attribute for link", async function (assert) {
|
||||||
|
const template = hbs`<Sidebar::SectionLink @linkName="test" @route="discovery.latest" @class="123 abc" />`;
|
||||||
|
|
||||||
|
await render(template);
|
||||||
|
|
||||||
|
assert.strictEqual(
|
||||||
|
query("a").className,
|
||||||
|
"sidebar-section-link sidebar-section-link-test 123 abc ember-view",
|
||||||
|
"has the right class attribute for the link"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue