diff --git a/app/assets/javascripts/discourse/app/components/sidebar/section-link.js b/app/assets/javascripts/discourse/app/components/sidebar/section-link.js index 790a7b0f565..d8badbf436a 100644 --- a/app/assets/javascripts/discourse/app/components/sidebar/section-link.js +++ b/app/assets/javascripts/discourse/app/components/sidebar/section-link.js @@ -9,7 +9,16 @@ export default class SectionLink extends Component { } 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() { diff --git a/app/assets/javascripts/discourse/tests/integration/components/sidebar/section-link-test.js b/app/assets/javascripts/discourse/tests/integration/components/sidebar/section-link-test.js new file mode 100644 index 00000000000..f413c02faae --- /dev/null +++ b/app/assets/javascripts/discourse/tests/integration/components/sidebar/section-link-test.js @@ -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``; + + 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``; + + 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" + ); + }); +});