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/hidden-details-test.js
Andrei Prigorshnev 0a4cb65020
DEV: Fix some deprecation warnings in tests
- Import `exists()` instead of using the global function (#13010)
2021-05-11 14:04:33 +04:00

36 lines
985 B
JavaScript

import componentTest, {
setupRenderingTest,
} from "discourse/tests/helpers/component-test";
import {
discourseModule,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import hbs from "htmlbars-inline-precompile";
import I18n from "I18n";
discourseModule("Integration | Component | hidden-details", function (hooks) {
setupRenderingTest(hooks);
componentTest("Shows a link and turns link into details on click", {
template: hbs`{{hidden-details label=label details=details}}`,
beforeEach() {
this.set("label", "label");
this.set("details", "details");
},
async test(assert) {
assert.ok(exists(".btn-link"));
assert.ok(query(".btn-link span").innerText === I18n.t("label"));
assert.notOk(exists(".description"));
await click(".btn-link");
assert.notOk(exists(".btn-link"));
assert.ok(exists(".description"));
assert.ok(query(".description").innerText === "details");
},
});
});