mirror of
https://github.com/discourse/discourse.git
synced 2024-12-11 21:16:14 +08:00
0a5f548635
As part of this move, we are also renaming `discourse-chat` to `chat`.
30 lines
873 B
JavaScript
30 lines
873 B
JavaScript
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|
import hbs from "htmlbars-inline-precompile";
|
|
import { render, waitUntil } from "@ember/test-helpers";
|
|
import { module, test } from "qunit";
|
|
|
|
module("Discourse Chat | Component | on-visibility-action", function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
test("Calling an action on visibility gained", async function (assert) {
|
|
this.set("value", null);
|
|
this.set("display", false);
|
|
this.set("action", () => {
|
|
this.set("value", "foo");
|
|
});
|
|
|
|
this.set("root", document.querySelector("#ember-testing"));
|
|
|
|
await render(
|
|
hbs`{{#if display}}{{on-visibility-action action=action root=root}}{{/if}}`
|
|
);
|
|
|
|
assert.equal(this.value, null);
|
|
|
|
this.set("display", true);
|
|
await waitUntil(() => this.value !== null);
|
|
|
|
assert.equal(this.value, "foo");
|
|
});
|
|
});
|