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
Jarek Radosz 189bebb2e4
DEV: Modernize component tests (#17368)
* Use QUnit `module` instead of `discourseModule`
* Use QUnit `test` instead of `componentTest`
* Use angle-bracket syntax
* Remove jQuery usage
* Improve assertions (and actually fix some of them)
2022-07-11 12:29:44 +02:00

36 lines
1021 B
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 "htmlbars-inline-precompile";
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", 32);
assert.strictEqual(this.foo, null);
await triggerKeyEvent(".btn-flat", "keydown", 13);
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");
});
});