import { module, test } from "qunit"; import { setupRenderingTest } from "discourse/tests/helpers/component-test"; import { render } from "@ember/test-helpers"; import { exists, query } from "discourse/tests/helpers/qunit-helpers"; import { hbs } from "ember-cli-htmlbars"; module("Integration | Component | Widget | button", function (hooks) { setupRenderingTest(hooks); test("icon only button", async function (assert) { this.set("args", { icon: "far-smile" }); await render(hbs``); assert.ok(exists("button.btn.btn-icon.no-text"), "it has all the classes"); assert.ok(exists("button .d-icon.d-icon-far-smile"), "it has the icon"); }); test("icon and text button", async function (assert) { this.set("args", { icon: "plus", label: "topic.create" }); await render(hbs``); assert.ok(exists("button.btn.btn-icon-text"), "it has all the classes"); assert.ok(exists("button .d-icon.d-icon-plus"), "it has the icon"); assert.ok(exists("button span.d-button-label"), "it has the label"); }); test("emoji and text button", async function (assert) { this.set("args", { emoji: "mega", label: "topic.create" }); await render(hbs``); assert.ok(exists("button.widget-button"), "renders the widget"); assert.ok(exists("button img.emoji"), "it renders the emoji"); assert.ok(exists("button span.d-button-label"), "it renders the label"); }); test("text only button", async function (assert) { this.set("args", { label: "topic.create" }); await render(hbs``); assert.ok(exists("button.btn.btn-text"), "it has all the classes"); assert.ok(exists("button span.d-button-label"), "it has the label"); }); test("translatedLabel", async function (assert) { this.set("args", { translatedLabel: "foo bar" }); await render(hbs``); assert.strictEqual( query("button span.d-button-label").innerText, "foo bar" ); }); test("translatedTitle", async function (assert) { this.set("args", { label: "topic.create", translatedTitle: "foo bar" }); await render(hbs``); assert.strictEqual(query("button").title, "foo bar"); }); });