discourse/test/javascripts/acceptance/modal-test.js.es6

65 lines
1.6 KiB
Plaintext
Raw Normal View History

import { acceptance } from "helpers/qunit-helpers";
2018-06-15 23:03:24 +08:00
import showModal from "discourse/lib/show-modal";
acceptance("Modal");
2017-06-15 01:57:58 +08:00
QUnit.test("modal", assert => {
2018-06-15 23:03:24 +08:00
visit("/");
andThen(() => {
2018-06-15 23:03:24 +08:00
assert.ok(
find(".d-modal:visible").length === 0,
"there is no modal at first"
);
});
2018-06-15 23:03:24 +08:00
click(".login-button");
andThen(() => {
2018-06-15 23:03:24 +08:00
assert.ok(find(".d-modal:visible").length === 1, "modal should appear");
});
2018-06-15 23:03:24 +08:00
click(".modal-outer-container");
andThen(() => {
2018-06-15 23:03:24 +08:00
assert.ok(
find(".d-modal:visible").length === 0,
"modal should disappear when you click outside"
);
});
2018-06-15 23:03:24 +08:00
click(".login-button");
andThen(() => {
2018-06-15 23:03:24 +08:00
assert.ok(find(".d-modal:visible").length === 1, "modal should reappear");
});
2018-06-15 23:03:24 +08:00
keyEvent("#main-outlet", "keydown", 27);
andThen(() => {
2018-06-15 23:03:24 +08:00
assert.ok(
find(".d-modal:visible").length === 0,
"ESC should close the modal"
);
});
andThen(() => {
2018-06-15 23:03:24 +08:00
Ember.TEMPLATES["modal/not-dismissable"] = Ember.HTMLBars.compile(
'{{#d-modal-body title="" class="" dismissable=false}}test{{/d-modal-body}}'
);
showModal("not-dismissable", {});
});
andThen(() => {
2018-06-15 23:03:24 +08:00
assert.ok(find(".d-modal:visible").length === 1, "modal should appear");
});
2018-06-15 23:03:24 +08:00
click(".modal-outer-container");
andThen(() => {
2018-06-15 23:03:24 +08:00
assert.ok(
find(".d-modal:visible").length === 1,
"modal should not disappear when you click outside"
);
});
2018-06-15 23:03:24 +08:00
keyEvent("#main-outlet", "keydown", 27);
andThen(() => {
2018-06-15 23:03:24 +08:00
assert.ok(
find(".d-modal:visible").length === 1,
"ESC should not close the modal"
);
});
});