FIX: ensures onSelect/onDeselect are called

This commit also add a FIX and a test for toolbar-popup-menu-options which had a behavior slightly specific.
This commit is contained in:
Joffrey JAFFEUX
2018-09-18 11:31:23 +02:00
committed by GitHub
parent fadcd36f92
commit a713c0d366
5 changed files with 87 additions and 5 deletions
@@ -289,6 +289,35 @@ QUnit.test("Composer can toggle between edit and reply", async assert => {
);
});
QUnit.test("Composer can toggle whispers", async assert => {
await visit("/t/this-is-a-test-topic/9");
await click(".topic-post:eq(0) button.reply");
await selectKit(".toolbar-popup-menu-options").expand();
await selectKit(".toolbar-popup-menu-options").selectRowByValue(
"toggleWhisper"
);
assert.ok(
find(".composer-fields .whisper")
.text()
.indexOf(I18n.t("composer.whisper")) > 0,
"it sets the post type to whisper"
);
await selectKit(".toolbar-popup-menu-options").expand();
await selectKit(".toolbar-popup-menu-options").selectRowByValue(
"toggleWhisper"
);
assert.ok(
find(".composer-fields .whisper")
.text()
.indexOf(I18n.t("composer.whisper")) <= 0,
"it removes the whisper mode"
);
});
QUnit.test(
"Composer can toggle between reply and createTopic",
async assert => {
@@ -835,3 +835,55 @@ componentTest("without forceEscape", {
);
}
});
componentTest("onSelect", {
template:
"<div class='test-external-action'></div>{{single-select content=content onSelect=(action externalAction)}}",
beforeEach() {
this.set("externalAction", actual => {
find(".test-external-action").text(actual);
});
this.set("content", ["red", "blue"]);
},
async test(assert) {
await this.get("subject").expand();
await this.get("subject").selectRowByValue("red");
assert.equal(
find(".test-external-action")
.text()
.trim(),
"red"
);
}
});
componentTest("onDeselect", {
template:
"<div class='test-external-action'></div>{{single-select content=content onDeselect=(action externalAction)}}",
beforeEach() {
this.set("externalAction", actual => {
find(".test-external-action").text(actual);
});
this.set("content", ["red", "blue"]);
},
async test(assert) {
await this.get("subject").expand();
await this.get("subject").selectRowByValue("red");
await this.get("subject").expand();
await this.get("subject").selectRowByValue("blue");
assert.equal(
find(".test-external-action")
.text()
.trim(),
"red"
);
}
});