This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/integration/components/flat-button-test.js
2022-07-17 20:15:28 +02:00

36 lines
1.0 KiB
JavaScript

import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { click, render, triggerKeyEvent } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
module("Integration | Component | flat-button", function (hooks) {
setupRenderingTest(hooks);
test("press Enter", async function (assert) {
this.set("foo", null);
this.set("action", () => {
this.set("foo", "bar");
});
await render(hbs`<FlatButton @action={{this.action}} />`);
await triggerKeyEvent(".btn-flat", "keydown", "Space");
assert.strictEqual(this.foo, null);
await triggerKeyEvent(".btn-flat", "keydown", "Enter");
assert.strictEqual(this.foo, "bar");
});
test("click", async function (assert) {
this.set("foo", null);
this.set("action", () => {
this.set("foo", "bar");
});
await render(hbs`<FlatButton @action={{this.action}} />`);
await click(".btn-flat");
assert.strictEqual(this.foo, "bar");
});
});