DEV: migrate tests to async/await

This commit is contained in:
Maja Komel
2018-07-29 22:51:32 +02:00
parent 176d8ca78d
commit 04baddf731
31 changed files with 1320 additions and 1729 deletions

View File

@ -24,8 +24,8 @@ QUnit.test("flagged posts - agree", async assert => {
await visit("/admin/flags/active");
await agreeFlag.expandAwait();
await agreeFlag.selectRowByValueAwait("confirm-agree-keep");
await agreeFlag.expand();
await agreeFlag.selectRowByValue("confirm-agree-keep");
assert.equal(
find(".admin-flags .flagged-post").length,
@ -39,8 +39,8 @@ QUnit.test("flagged posts - agree + hide", async assert => {
await visit("/admin/flags/active");
await agreeFlag.expandAwait();
await agreeFlag.selectRowByValueAwait("confirm-agree-hide");
await agreeFlag.expand();
await agreeFlag.selectRowByValue("confirm-agree-hide");
assert.equal(
find(".admin-flags .flagged-post").length,
@ -54,8 +54,8 @@ QUnit.test("flagged posts - agree + deleteSpammer", async assert => {
await visit("/admin/flags/active");
await agreeFlag.expandAwait();
await agreeFlag.selectRowByValueAwait("delete-spammer");
await agreeFlag.expand();
await agreeFlag.selectRowByValue("delete-spammer");
await click(".confirm-delete");
@ -85,8 +85,8 @@ QUnit.test("flagged posts - delete + defer", async assert => {
await visit("/admin/flags/active");
await deleteFlag.expandAwait();
await deleteFlag.selectRowByValueAwait("delete-defer");
await deleteFlag.expand();
await deleteFlag.selectRowByValue("delete-defer");
assert.equal(find(".admin-flags .flagged-post").length, 0);
});
@ -96,8 +96,8 @@ QUnit.test("flagged posts - delete + agree", async assert => {
await visit("/admin/flags/active");
await deleteFlag.expandAwait();
await deleteFlag.selectRowByValueAwait("delete-agree");
await deleteFlag.expand();
await deleteFlag.selectRowByValue("delete-agree");
assert.equal(find(".admin-flags .flagged-post").length, 0);
});
@ -107,8 +107,8 @@ QUnit.test("flagged posts - delete + deleteSpammer", async assert => {
await visit("/admin/flags/active");
await deleteFlag.expandAwait();
await deleteFlag.selectRowByValueAwait("delete-spammer");
await deleteFlag.expand();
await deleteFlag.selectRowByValue("delete-spammer");
await click(".confirm-delete");

View File

@ -50,8 +50,8 @@ QUnit.test("suspend, then unsuspend a user", async assert => {
"disabled by default"
);
await suspendUntilCombobox.expandAwait();
await suspendUntilCombobox.selectRowByValueAwait("tomorrow");
await suspendUntilCombobox.expand();
await suspendUntilCombobox.selectRowByValue("tomorrow");
await fillIn(".suspend-reason", "for breaking the rules");
await fillIn(".suspend-message", "this is an email reason why");

View File

@ -13,7 +13,7 @@ QUnit.test("does not display uncategorized if not allowed", async assert => {
await visit("/");
await click("#create-topic");
await categoryChooser.expandAwait();
await categoryChooser.expand();
assert.ok(categoryChooser.rowByIndex(0).name() !== "uncategorized");
});

View File

@ -33,7 +33,7 @@ QUnit.test("removing a permission", async assert => {
await click(".edit-category");
await click("li.edit-category-security a");
await click(".edit-category-tab-security .edit-permission");
await availableGroups.expandAwait();
await availableGroups.expand();
assert.notOk(
availableGroups.rowByValue("everyone").exists(),
@ -43,7 +43,7 @@ QUnit.test("removing a permission", async assert => {
await click(
".edit-category-tab-security .permission-list li:first-of-type .remove-permission"
);
await availableGroups.expandAwait();
await availableGroups.expand();
assert.ok(
availableGroups.rowByValue("everyone").exists(),
@ -60,10 +60,10 @@ QUnit.test("adding a permission", async assert => {
await click(".edit-category");
await click("li.edit-category-security a");
await click(".edit-category-tab-security .edit-permission");
await availableGroups.expandAwait();
await availableGroups.selectRowByValueAwait("staff");
await permissionSelector.expandAwait();
await permissionSelector.selectRowByValueAwait("2");
await availableGroups.expand();
await availableGroups.selectRowByValue("staff");
await permissionSelector.expand();
await permissionSelector.selectRowByValue("2");
await click(".edit-category-tab-security .add-permission");
const $addedPermissionItem = find(
@ -95,8 +95,8 @@ QUnit.test("adding a previously removed permission", async assert => {
"it removes the permission from the list"
);
await availableGroups.expandAwait();
await availableGroups.selectRowByValueAwait("everyone");
await availableGroups.expand();
await availableGroups.selectRowByValue("everyone");
await click(".edit-category-tab-security .add-permission");
assert.equal(

View File

@ -78,8 +78,8 @@ QUnit.test("Subcategory list settings", async assert => {
);
await click(".edit-category-general");
await categoryChooser.expandAwait();
await categoryChooser.selectRowByValueAwait(3);
await categoryChooser.expand();
await categoryChooser.selectRowByValue(3);
await click(".edit-category-settings a");

View File

@ -16,7 +16,7 @@ QUnit.test("replying to post", async assert => {
await visit("/t/internationalization-localization/280");
await click("article#post_3 button.reply");
await composerActions.expandAwait();
await composerActions.expand();
assert.equal(composerActions.rowByIndex(0).value(), "reply_as_new_topic");
assert.equal(
@ -34,8 +34,8 @@ QUnit.test("replying to post - reply_as_private_message", async assert => {
await visit("/t/internationalization-localization/280");
await click("article#post_3 button.reply");
await composerActions.expandAwait();
await composerActions.selectRowByValueAwait("reply_as_private_message");
await composerActions.expand();
await composerActions.selectRowByValue("reply_as_private_message");
assert.equal(find(".users-input .item:eq(0)").text(), "codinghorror");
assert.ok(
@ -55,8 +55,8 @@ QUnit.test("replying to post - reply_to_topic", async assert => {
"test replying to topic when initially replied to post"
);
await composerActions.expandAwait();
await composerActions.selectRowByValueAwait("reply_to_topic");
await composerActions.expand();
await composerActions.selectRowByValue("reply_to_topic");
assert.equal(
find(".action-title .topic-link")
@ -84,8 +84,8 @@ QUnit.test("replying to post - toggle_whisper", async assert => {
"test replying as whisper to topic when initially not a whisper"
);
await composerActions.expandAwait();
await composerActions.selectRowByValueAwait("toggle_whisper");
await composerActions.expand();
await composerActions.selectRowByValue("toggle_whisper");
assert.ok(
find(".composer-fields .whisper")
@ -103,15 +103,15 @@ QUnit.test("replying to post - reply_as_new_topic", async assert => {
await visit("/t/internationalization-localization/280");
await click("#topic-title .d-icon-pencil");
await categoryChooser.expandAwait();
await categoryChooser.selectRowByValueAwait(4);
await categoryChooser.expand();
await categoryChooser.selectRowByValue(4);
await click("#topic-title .submit-edit");
await click("article#post_3 button.reply");
await fillIn(".d-editor-input", quote);
await composerActions.expandAwait();
await composerActions.selectRowByValueAwait("reply_as_new_topic");
await composerActions.expand();
await composerActions.selectRowByValue("reply_as_new_topic");
assert.equal(categoryChooserReplyArea.header().name(), "faq");
assert.equal(
@ -133,8 +133,8 @@ QUnit.test("shared draft", async assert => {
await visit("/");
await click("#create-topic");
await composerActions.expandAwait();
await composerActions.selectRowByValueAwait("shared_draft");
await composerActions.expand();
await composerActions.selectRowByValue("shared_draft");
assert.equal(
find("#reply-control .btn-primary.create .d-button-label").text(),
@ -159,8 +159,8 @@ QUnit.test("interactions", async assert => {
await visit("/t/internationalization-localization/280");
await click("article#post_3 button.reply");
await fillIn(".d-editor-input", quote);
await composerActions.expandAwait();
await composerActions.selectRowByValueAwait("reply_to_topic");
await composerActions.expand();
await composerActions.selectRowByValue("reply_to_topic");
assert.equal(
find(".action-title")
@ -170,7 +170,7 @@ QUnit.test("interactions", async assert => {
);
assert.equal(find(".d-editor-input").val(), quote);
await composerActions.expandAwait();
await composerActions.expand();
assert.equal(composerActions.rowByIndex(0).value(), "reply_as_new_topic");
assert.equal(composerActions.rowByIndex(1).value(), "reply_to_post");
@ -181,8 +181,8 @@ QUnit.test("interactions", async assert => {
assert.equal(composerActions.rowByIndex(3).value(), "toggle_whisper");
assert.equal(composerActions.rows().length, 4);
await composerActions.selectRowByValueAwait("reply_to_post");
await composerActions.expandAwait();
await composerActions.selectRowByValue("reply_to_post");
await composerActions.expand();
assert.ok(exists(find(".action-title img.avatar")));
assert.equal(
@ -201,8 +201,8 @@ QUnit.test("interactions", async assert => {
assert.equal(composerActions.rowByIndex(3).value(), "toggle_whisper");
assert.equal(composerActions.rows().length, 4);
await composerActions.selectRowByValueAwait("reply_as_new_topic");
await composerActions.expandAwait();
await composerActions.selectRowByValue("reply_as_new_topic");
await composerActions.expand();
assert.equal(
find(".action-title")
@ -224,8 +224,8 @@ QUnit.test("interactions", async assert => {
assert.equal(composerActions.rowByIndex(3).value(), "shared_draft");
assert.equal(composerActions.rows().length, 4);
await composerActions.selectRowByValueAwait("reply_as_private_message");
await composerActions.expandAwait();
await composerActions.selectRowByValue("reply_as_private_message");
await composerActions.expand();
assert.equal(
find(".action-title")

View File

@ -295,8 +295,8 @@ QUnit.test(
await visit("/t/this-is-a-test-topic/9");
await click(".topic-post:eq(0) button.reply");
await selectKit(".toolbar-popup-menu-options").expandAwait();
await selectKit(".toolbar-popup-menu-options").selectRowByValueAwait(
await selectKit(".toolbar-popup-menu-options").expand();
await selectKit(".toolbar-popup-menu-options").selectRowByValue(
"toggleWhisper"
);
@ -318,8 +318,8 @@ QUnit.test(
"it should reset the state of the composer's model"
);
await selectKit(".toolbar-popup-menu-options").expandAwait();
await selectKit(".toolbar-popup-menu-options").selectRowByValueAwait(
await selectKit(".toolbar-popup-menu-options").expand();
await selectKit(".toolbar-popup-menu-options").selectRowByValue(
"toggleInvisible"
);
@ -409,8 +409,8 @@ QUnit.test("Disable body until category is selected", async assert => {
const categoryChooser = selectKit(".category-chooser");
await categoryChooser.expandAwait();
await categoryChooser.selectRowByValueAwait(2);
await categoryChooser.expand();
await categoryChooser.selectRowByValue(2);
assert.ok(
find(".d-editor-textarea-wrapper.disabled").length === 0,
@ -418,8 +418,8 @@ QUnit.test("Disable body until category is selected", async assert => {
);
await fillIn(".d-editor-input", "Now I can type stuff");
await categoryChooser.expandAwait();
await categoryChooser.selectRowByValueAwait("__none__");
await categoryChooser.expand();
await categoryChooser.selectRowByValue("__none__");
assert.ok(
find(".d-editor-textarea-wrapper.disabled").length === 0,

View File

@ -58,9 +58,12 @@ QUnit.test("update some fields", async assert => {
await savePreferences();
click(".preferences-nav .nav-notifications a");
selectKit(".control-group.notifications .combo-box.duration")
.expand()
.selectRowByValue(1440);
await selectKit(
".control-group.notifications .combo-box.duration"
).expand();
await selectKit(
".control-group.notifications .combo-box.duration"
).selectRowByValue(1440);
await savePreferences();
click(".preferences-nav .nav-categories a");

View File

@ -156,9 +156,9 @@ QUnit.test("update category through advanced search ui", async assert => {
await fillIn(".search-query", "none");
await categoryChooser.expandAwait();
await categoryChooser.expand();
await categoryChooser.fillInFilter("faq");
await categoryChooser.selectRowByValueAwait(4);
await categoryChooser.selectRowByValue(4);
assert.ok(
exists('.search-advanced-options .badge-category:contains("faq")'),
@ -317,8 +317,8 @@ QUnit.test("update in filter through advanced search ui", async assert => {
await visit("/search");
await fillIn(".search-query", "none");
await inSelector.expandAwait();
await inSelector.selectRowByValueAwait("bookmarks");
await inSelector.expand();
await inSelector.selectRowByValue("bookmarks");
assert.ok(
inSelector.rowByName("I bookmarked").exists(),
@ -339,8 +339,8 @@ QUnit.test("update status through advanced search ui", async assert => {
await visit("/search");
await fillIn(".search-query", "none");
await statusSelector.expandAwait();
await statusSelector.selectRowByValueAwait("closed");
await statusSelector.expand();
await statusSelector.selectRowByValue("closed");
assert.ok(
statusSelector.rowByName("are closed").exists(),
@ -362,8 +362,8 @@ QUnit.test("update post time through advanced search ui", async assert => {
await fillIn(".search-query", "none");
await fillIn("#search-post-date .date-picker", "2016-10-05");
await postTimeSelector.expandAwait();
await postTimeSelector.selectRowByValueAwait("after");
await postTimeSelector.expand();
await postTimeSelector.selectRowByValue("after");
assert.ok(
postTimeSelector.rowByName("after").exists(),

View File

@ -89,7 +89,7 @@ QUnit.test("Right filters are shown to anonymous users", async assert => {
await visit("/search?expanded=true");
await inSelector.expandAwait();
await inSelector.expand();
assert.ok(inSelector.rowByValue("first").exists());
assert.ok(inSelector.rowByValue("pinned").exists());
@ -115,7 +115,7 @@ QUnit.test("Right filters are shown to logged-in users", async assert => {
Discourse.reset();
await visit("/search?expanded=true");
await inSelector.expandAwait();
await inSelector.expand();
assert.ok(inSelector.rowByValue("first").exists());
assert.ok(inSelector.rowByValue("pinned").exists());

View File

@ -51,8 +51,8 @@ QUnit.test("autoclose - specific time", async assert => {
await click(".toggle-admin-menu");
await click(".topic-admin-status-update button");
await futureDateInputSelector.expandAwait();
await futureDateInputSelector.selectRowByValueAwait("next_week");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("next_week");
assert.equal(futureDateInputSelector.header().title(), "Next week");
assert.equal(futureDateInputSelector.header().value(), "next_week");
@ -71,8 +71,8 @@ QUnit.test("autoclose", async assert => {
await click(".toggle-admin-menu");
await click(".topic-admin-status-update button");
await futureDateInputSelector.expandAwait();
await futureDateInputSelector.selectRowByValueAwait("next_week");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("next_week");
assert.equal(futureDateInputSelector.header().title(), "Next week");
assert.equal(futureDateInputSelector.header().value(), "next_week");
@ -83,8 +83,8 @@ QUnit.test("autoclose", async assert => {
.trim();
assert.ok(regex1.test(html1));
await futureDateInputSelector.expandAwait();
await futureDateInputSelector.selectRowByValueAwait("pick_date_and_time");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("pick_date_and_time");
await fillIn(".future-date-input .date-picker", "2099-11-24");
@ -97,8 +97,8 @@ QUnit.test("autoclose", async assert => {
.trim();
assert.ok(regex2.test(html2));
await futureDateInputSelector.expandAwait();
await futureDateInputSelector.selectRowByValueAwait("set_based_on_last_post");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("set_based_on_last_post");
await fillIn(".future-date-input input[type=number]", "2");
@ -126,14 +126,14 @@ QUnit.test("close temporarily", async assert => {
await click(".toggle-admin-menu");
await click(".topic-admin-status-update button");
await timerType.expandAwait();
await timerType.selectRowByValueAwait("open");
await timerType.expand();
await timerType.selectRowByValue("open");
assert.equal(futureDateInputSelector.header().title(), "Select a timeframe");
assert.equal(futureDateInputSelector.header().value(), null);
await futureDateInputSelector.expandAwait();
await futureDateInputSelector.selectRowByValueAwait("next_week");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("next_week");
assert.equal(futureDateInputSelector.header().title(), "Next week");
assert.equal(futureDateInputSelector.header().value(), "next_week");
@ -144,8 +144,8 @@ QUnit.test("close temporarily", async assert => {
.trim();
assert.ok(regex1.test(html1));
await futureDateInputSelector.expandAwait();
await futureDateInputSelector.selectRowByValueAwait("pick_date_and_time");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("pick_date_and_time");
await fillIn(".future-date-input .date-picker", "2099-11-24");
@ -168,8 +168,8 @@ QUnit.test("schedule", async assert => {
await click(".toggle-admin-menu");
await click(".topic-admin-status-update button");
await timerType.expandAwait();
await timerType.selectRowByValueAwait("publish_to_category");
await timerType.expand();
await timerType.selectRowByValue("publish_to_category");
assert.equal(categoryChooser.header().title(), "uncategorized");
assert.equal(categoryChooser.header().value(), null);
@ -177,11 +177,11 @@ QUnit.test("schedule", async assert => {
assert.equal(futureDateInputSelector.header().title(), "Select a timeframe");
assert.equal(futureDateInputSelector.header().value(), null);
await categoryChooser.expandAwait();
await categoryChooser.selectRowByValueAwait("7");
await categoryChooser.expand();
await categoryChooser.selectRowByValue("7");
await futureDateInputSelector.expandAwait();
await futureDateInputSelector.selectRowByValueAwait("next_week");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("next_week");
assert.equal(futureDateInputSelector.header().title(), "Next week");
assert.equal(futureDateInputSelector.header().value(), "next_week");
@ -202,7 +202,7 @@ QUnit.test("TL4 can't auto-delete", async assert => {
const timerType = selectKit(".select-kit.timer-type");
await timerType.expandAwait();
await timerType.expand();
assert.ok(!timerType.rowByValue("delete").exists());
});
@ -215,14 +215,14 @@ QUnit.test("auto delete", async assert => {
await click(".toggle-admin-menu");
await click(".topic-admin-status-update button");
await timerType.expandAwait();
await timerType.selectRowByValueAwait("delete");
await timerType.expand();
await timerType.selectRowByValue("delete");
assert.equal(futureDateInputSelector.header().title(), "Select a timeframe");
assert.equal(futureDateInputSelector.header().value(), null);
await futureDateInputSelector.expandAwait();
await futureDateInputSelector.selectRowByValueAwait("two_weeks");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("two_weeks");
assert.equal(futureDateInputSelector.header().title(), "Two Weeks");
assert.equal(futureDateInputSelector.header().value(), "two_weeks");
@ -242,7 +242,8 @@ QUnit.test(
await visit("/t/internationalization-localization");
await click(".toggle-admin-menu");
await click(".topic-admin-status-update button");
await futureDateInputSelector.expand().selectRowByValue("next_week");
await futureDateInputSelector.expand();
await futureDateInputSelector.selectRowByValue("next_week");
await click(".modal-footer button.btn-primary");
const regex = /will automatically close in/g;

View File

@ -20,8 +20,8 @@ QUnit.test("Updating topic notification level", async assert => {
"it should display the notification options button in the topic's footer"
);
await notificationOptions.expandAwait();
await notificationOptions.selectRowByValueAwait("3");
await notificationOptions.expand();
await notificationOptions.selectRowByValue("3");
assert.equal(
notificationOptions.selectedRow().name(),

View File

@ -54,8 +54,8 @@ QUnit.test("Updating the topic title and category", async assert => {
await click("#topic-title .d-icon-pencil");
await fillIn("#edit-title", "this is the new title");
await categoryChooser.expandAwait();
await categoryChooser.selectRowByValueAwait(4);
await categoryChooser.expand();
await categoryChooser.selectRowByValue(4);
await click("#topic-title .submit-edit");
assert.equal(

View File

@ -10,7 +10,7 @@ componentTest("default", {
assert.equal(subject.el().find(".d-icon-bars").length, 1);
assert.equal(subject.el().find(".d-icon-caret-down").length, 1);
await subject.expandAwait();
await subject.expand();
assert.equal(subject.rowByValue("create").name(), "New Category");
}

View File

@ -30,7 +30,7 @@ componentTest("with excludeCategoryId", {
template: "{{category-chooser excludeCategoryId=2}}",
async test(assert) {
await this.get("subject").expandAwait();
await this.get("subject").expand();
assert.notOk(
this.get("subject")
@ -44,7 +44,7 @@ componentTest("with scopedCategoryId", {
template: "{{category-chooser scopedCategoryId=2}}",
async test(assert) {
await this.get("subject").expandAwait();
await this.get("subject").expand();
assert.equal(
this.get("subject")

View File

@ -16,20 +16,18 @@ componentTest("default", {
},
test(assert) {
andThen(() => {
assert.equal(
this.get("subject")
.header()
.value(),
2
);
assert.notOk(
this.get("subject")
.rowByValue(2)
.exists(),
"selected categories are not in the list"
);
});
assert.equal(
this.get("subject")
.header()
.value(),
2
);
assert.notOk(
this.get("subject")
.rowByValue(2)
.exists(),
"selected categories are not in the list"
);
}
});
@ -41,23 +39,21 @@ componentTest("with blacklist", {
this.set("blacklist", [Category.findById(8)]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() => {
assert.ok(
this.get("subject")
.rowByValue(6)
.exists(),
"not blacklisted categories are in the list"
);
assert.notOk(
this.get("subject")
.rowByValue(8)
.exists(),
"blacklisted categories are not in the list"
);
});
assert.ok(
this.get("subject")
.rowByValue(6)
.exists(),
"not blacklisted categories are in the list"
);
assert.notOk(
this.get("subject")
.rowByValue(8)
.exists(),
"blacklisted categories are not in the list"
);
}
});
@ -68,39 +64,31 @@ componentTest("interactions", {
this.set("categories", [Category.findById(2), Category.findById(6)]);
},
test(assert) {
this.get("subject")
.expand()
.selectRowByValue(8);
async test(assert) {
await this.get("subject").expand();
await this.get("subject").selectRowByValue(8);
andThen(() => {
assert.equal(
this.get("subject")
.header()
.value(),
"2,6,8",
"it adds the selected category"
);
assert.equal(this.get("categories").length, 3);
});
assert.equal(
this.get("subject")
.header()
.value(),
"2,6,8",
"it adds the selected category"
);
assert.equal(this.get("categories").length, 3);
this.get("subject").expand();
this.get("subject")
.keyboard()
.backspace();
this.get("subject")
.keyboard()
.backspace();
await this.get("subject").expand();
andThen(() => {
assert.equal(
this.get("subject")
.header()
.value(),
"2,6",
"it removes the last selected category"
);
assert.equal(this.get("categories").length, 2);
});
await this.get("subject").keyboard("backspace");
await this.get("subject").keyboard("backspace");
assert.equal(
this.get("subject")
.header()
.value(),
"2,6",
"it removes the last selected category"
);
assert.equal(this.get("categories").length, 2);
}
});

View File

@ -13,7 +13,7 @@ componentTest("default", {
},
async test(assert) {
await this.get("subject").expandAwait();
await this.get("subject").expand();
assert.equal(
this.get("subject")
@ -46,7 +46,7 @@ componentTest("with valueAttribute", {
},
async test(assert) {
await this.get("subject").expandAwait();
await this.get("subject").expand();
assert.equal(
this.get("subject")
@ -70,7 +70,7 @@ componentTest("with nameProperty", {
},
async test(assert) {
await this.get("subject").expandAwait();
await this.get("subject").expand();
assert.equal(
this.get("subject")
@ -94,7 +94,7 @@ componentTest("with an array as content", {
},
async test(assert) {
await this.get("subject").expandAwait();
await this.get("subject").expand();
assert.equal(
this.get("subject")
@ -120,7 +120,7 @@ componentTest("with value and none as a string", {
},
async test(assert) {
await this.get("subject").expandAwait();
await this.get("subject").expand();
assert.equal(
this.get("subject")
@ -148,7 +148,7 @@ componentTest("with value and none as a string", {
);
assert.equal(this.get("value"), "trout");
await this.get("subject").selectNoneRowAwait();
await this.get("subject").selectNoneRow();
assert.equal(this.get("value"), null);
}
@ -191,7 +191,7 @@ componentTest("with value and none as an object", {
);
assert.equal(this.get("value"), "evil");
await this.get("subject").selectNoneRowAwait();
await this.get("subject").selectNoneRow();
assert.equal(this.get("value"), null);
}
@ -207,7 +207,7 @@ componentTest("with no value and none as an object", {
},
async test(assert) {
await this.get("subject").expandAwait();
await this.get("subject").expand();
assert.equal(
this.get("subject")
@ -228,7 +228,7 @@ componentTest("with no value and none string", {
},
async test(assert) {
await this.get("subject").expandAwait();
await this.get("subject").expand();
assert.equal(
this.get("subject")
@ -247,7 +247,7 @@ componentTest("with no value and no none", {
},
async test(assert) {
await this.get("subject").expandAwait();
await this.get("subject").expand();
assert.equal(
this.get("subject")
@ -289,7 +289,7 @@ componentTest("with noneLabel", {
},
async test(assert) {
await this.get("subject").expandAwait();
await this.get("subject").expand();
assert.equal(
this.get("subject")

File diff suppressed because it is too large Load Diff

View File

@ -11,20 +11,18 @@ componentTest("default", {
},
test(assert) {
andThen(() => {
assert.equal(
selectKit()
.header()
.title(),
"bold,italic"
);
assert.equal(
selectKit()
.header()
.value(),
"bold,italic"
);
});
assert.equal(
selectKit()
.header()
.title(),
"bold,italic"
);
assert.equal(
selectKit()
.header()
.value(),
"bold,italic"
);
}
});
@ -36,14 +34,12 @@ componentTest("with empty string as value", {
},
test(assert) {
andThen(() => {
assert.equal(
selectKit()
.header()
.value(),
""
);
});
assert.equal(
selectKit()
.header()
.value(),
""
);
}
});
@ -55,14 +51,12 @@ componentTest("with only setting value", {
},
test(assert) {
andThen(() => {
assert.equal(
selectKit()
.header()
.value(),
"bold,italic"
);
});
assert.equal(
selectKit()
.header()
.value(),
"bold,italic"
);
}
});
@ -74,35 +68,26 @@ componentTest("interactions", {
this.set("choices", ["bold", "italic", "underline"]);
},
test(assert) {
async test(assert) {
const listSetting = selectKit();
listSetting.expand().selectRowByValue("underline");
await listSetting.expand();
await listSetting.selectRowByValue("underline");
andThen(() => {
assert.equal(listSetting.header().value(), "bold,italic,underline");
});
assert.equal(listSetting.header().value(), "bold,italic,underline");
listSetting.expand().fillInFilter("strike");
await listSetting.expand();
await listSetting.fillInFilter("strike");
andThen(() => {
assert.equal(listSetting.highlightedRow().value(), "strike");
});
assert.equal(listSetting.highlightedRow().value(), "strike");
listSetting.keyboard().enter();
await listSetting.keyboard("enter");
andThen(() => {
assert.equal(
listSetting.header().value(),
"bold,italic,underline,strike"
);
});
assert.equal(listSetting.header().value(), "bold,italic,underline,strike");
listSetting.keyboard().backspace();
listSetting.keyboard().backspace();
await listSetting.keyboard("backspace");
await listSetting.keyboard("backspace");
andThen(() => {
assert.equal(listSetting.header().value(), "bold,italic,underline");
});
assert.equal(listSetting.header().value(), "bold,italic,underline");
}
});

View File

@ -15,14 +15,12 @@ componentTest("with objects and values", {
},
test(assert) {
andThen(() => {
assert.equal(
this.get("subject")
.header()
.value(),
"1,2"
);
});
assert.equal(
this.get("subject")
.header()
.value(),
"1,2"
);
}
});
@ -34,13 +32,11 @@ componentTest("with title", {
},
test(assert) {
andThen(() =>
assert.equal(
selectKit()
.header()
.title(),
"My title"
)
assert.equal(
selectKit()
.header()
.title(),
"My title"
);
}
});
@ -58,165 +54,127 @@ componentTest("interactions", {
this.set("values", [1, 2]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() => {
assert.equal(
this.get("subject")
.highlightedRow()
.name(),
"robin",
"it highlights the first content row"
);
});
assert.equal(
this.get("subject")
.highlightedRow()
.name(),
"robin",
"it highlights the first content row"
);
this.set("none", "test.none");
await this.set("none", "test.none");
andThen(() => {
assert.ok(
this.get("subject")
.noneRow()
.exists()
);
assert.equal(
this.get("subject")
.highlightedRow()
.name(),
"robin",
"it highlights the first content row"
);
});
assert.ok(
this.get("subject")
.noneRow()
.exists()
);
assert.equal(
this.get("subject")
.highlightedRow()
.name(),
"robin",
"it highlights the first content row"
);
this.get("subject").selectRowByValue(3);
this.get("subject").expand();
await this.get("subject").selectRowByValue(3);
await this.get("subject").expand();
andThen(() => {
assert.equal(
this.get("subject")
.highlightedRow()
.name(),
"none",
"it highlights none row if no content"
);
});
assert.equal(
this.get("subject")
.highlightedRow()
.name(),
"none",
"it highlights none row if no content"
);
this.get("subject").fillInFilter("joffrey");
await this.get("subject").fillInFilter("joffrey");
andThen(() => {
assert.equal(
this.get("subject")
.highlightedRow()
.name(),
"joffrey",
"it highlights create row when filling filter"
);
});
assert.equal(
this.get("subject")
.highlightedRow()
.name(),
"joffrey",
"it highlights create row when filling filter"
);
this.get("subject")
.keyboard()
.enter();
await this.get("subject").keyboard("enter");
andThen(() => {
assert.equal(
this.get("subject")
.highlightedRow()
.name(),
"none",
"it highlights none row after creating content and no content left"
);
});
assert.equal(
this.get("subject")
.highlightedRow()
.name(),
"none",
"it highlights none row after creating content and no content left"
);
this.get("subject")
.keyboard()
.backspace();
await this.get("subject").keyboard("backspace");
andThen(() => {
const $lastSelectedName = this.get("subject")
.header()
.el()
.find(".selected-name")
.last();
assert.equal($lastSelectedName.attr("data-name"), "joffrey");
assert.ok(
$lastSelectedName.hasClass("is-highlighted"),
"it highlights the last selected name when using backspace"
);
});
const $lastSelectedName = this.get("subject")
.header()
.el()
.find(".selected-name")
.last();
assert.equal($lastSelectedName.attr("data-name"), "joffrey");
assert.ok(
$lastSelectedName.hasClass("is-highlighted"),
"it highlights the last selected name when using backspace"
);
this.get("subject")
.keyboard()
.backspace();
await this.get("subject").keyboard("backspace");
andThen(() => {
const $lastSelectedName = this.get("subject")
.header()
.el()
.find(".selected-name")
.last();
assert.equal(
$lastSelectedName.attr("data-name"),
"robin",
"it removes the previous highlighted selected content"
);
assert.notOk(
this.get("subject")
.rowByValue("joffrey")
.exists(),
"generated content shouldn’t appear in content when removed"
);
});
const $lastSelectedName1 = this.get("subject")
.header()
.el()
.find(".selected-name")
.last();
assert.equal(
$lastSelectedName1.attr("data-name"),
"robin",
"it removes the previous highlighted selected content"
);
assert.notOk(
this.get("subject")
.rowByValue("joffrey")
.exists(),
"generated content shouldn’t appear in content when removed"
);
this.get("subject")
.keyboard()
.selectAll();
await this.get("subject").keyboard("selectAll");
andThen(() => {
const $highlightedSelectedNames = this.get("subject")
.header()
.el()
.find(".selected-name.is-highlighted");
assert.equal(
$highlightedSelectedNames.length,
3,
"it highlights each selected name"
);
});
const $highlightedSelectedNames2 = this.get("subject")
.header()
.el()
.find(".selected-name.is-highlighted");
assert.equal(
$highlightedSelectedNames2.length,
3,
"it highlights each selected name"
);
this.get("subject")
.keyboard()
.backspace();
await this.get("subject").keyboard("backspace");
andThen(() => {
const $selectedNames = this.get("subject")
.header()
.el()
.find(".selected-name");
assert.equal($selectedNames.length, 0, "it removed all selected content");
});
const $selectedNames = this.get("subject")
.header()
.el()
.find(".selected-name");
assert.equal($selectedNames.length, 0, "it removed all selected content");
andThen(() => {
assert.ok(this.get("subject").isFocused());
assert.ok(this.get("subject").isExpanded());
});
assert.ok(this.get("subject").isFocused());
assert.ok(this.get("subject").isExpanded());
this.get("subject")
.keyboard()
.escape();
await this.get("subject").keyboard("escape");
andThen(() => {
assert.ok(this.get("subject").isFocused());
assert.notOk(this.get("subject").isExpanded());
});
assert.ok(this.get("subject").isFocused());
assert.notOk(this.get("subject").isExpanded());
this.get("subject")
.keyboard()
.escape();
await this.get("subject").keyboard("escape");
andThen(() => {
assert.notOk(this.get("subject").isFocused());
assert.notOk(this.get("subject").isExpanded());
});
assert.notOk(this.get("subject").isFocused());
assert.notOk(this.get("subject").isExpanded());
}
});
@ -227,16 +185,14 @@ componentTest("with limitMatches", {
this.set("content", ["sam", "jeff", "neil"]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() =>
assert.equal(
this.get("subject")
.el()
.find(".select-kit-row").length,
2
)
assert.equal(
this.get("subject")
.el()
.find(".select-kit-row").length,
2
);
}
});
@ -248,26 +204,22 @@ componentTest("with minimum", {
this.set("content", ["sam", "jeff", "neil"]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() =>
assert.equal(
this.get("subject").validationMessage(),
"Select at least 1 item."
)
assert.equal(
this.get("subject").validationMessage(),
"Select at least 1 item."
);
this.get("subject").selectRowByValue("sam");
await this.get("subject").selectRowByValue("sam");
andThen(() => {
assert.equal(
this.get("subject")
.header()
.label(),
"sam"
);
});
assert.equal(
this.get("subject")
.header()
.label(),
"sam"
);
}
});
@ -280,22 +232,18 @@ componentTest("with minimumLabel", {
this.set("content", ["sam", "jeff", "neil"]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() =>
assert.equal(this.get("subject").validationMessage(), "min 1")
assert.equal(this.get("subject").validationMessage(), "min 1");
await this.get("subject").selectRowByValue("jeff");
assert.equal(
this.get("subject")
.header()
.label(),
"jeff"
);
this.get("subject").selectRowByValue("jeff");
andThen(() => {
assert.equal(
this.get("subject")
.header()
.label(),
"jeff"
);
});
}
});

View File

@ -16,30 +16,24 @@ componentTest("updating the content refreshes the list", {
this.set("content", [{ id: 1, name: "BEFORE" }]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() => {
assert.equal(
this.get("subject")
.rowByValue(1)
.name(),
"BEFORE"
);
});
assert.equal(
this.get("subject")
.rowByValue(1)
.name(),
"BEFORE"
);
andThen(() => {
this.set("content", [{ id: 1, name: "AFTER" }]);
});
await this.set("content", [{ id: 1, name: "AFTER" }]);
andThen(() => {
assert.equal(
this.get("subject")
.rowByValue(1)
.name(),
"AFTER"
);
});
assert.equal(
this.get("subject")
.rowByValue(1)
.name(),
"AFTER"
);
}
});
@ -51,24 +45,20 @@ componentTest("accepts a value by reference", {
this.set("content", [{ id: 1, name: "robin" }, { id: 2, name: "regis" }]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() => {
assert.equal(
this.get("subject")
.selectedRow()
.name(),
"robin",
"it highlights the row corresponding to the value"
);
});
assert.equal(
this.get("subject")
.selectedRow()
.name(),
"robin",
"it highlights the row corresponding to the value"
);
this.get("subject").selectRowByValue(1);
await this.get("subject").selectRowByValue(1);
andThen(() => {
assert.equal(this.get("value"), 1, "it mutates the value");
});
assert.equal(this.get("value"), 1, "it mutates the value");
}
});
@ -89,69 +79,63 @@ componentTest("no default icon", {
componentTest("default search icon", {
template: "{{single-select filterable=true}}",
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() => {
assert.ok(
exists(
this.get("subject")
.filter()
.icon()
),
"it has an icon"
);
});
assert.ok(
exists(
this.get("subject")
.filter()
.icon()
),
"it has an icon"
);
}
});
componentTest("with no search icon", {
template: "{{single-select filterable=true filterIcon=null}}",
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() => {
assert.notOk(
exists(
this.get("subject")
.filter()
.icon()
),
"it has no icon"
);
});
assert.notOk(
exists(
this.get("subject")
.filter()
.icon()
),
"it has no icon"
);
}
});
componentTest("custom search icon", {
template: '{{single-select filterable=true filterIcon="shower"}}',
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() => {
assert.ok(
this.get("subject")
.filter()
.icon()
.hasClass("d-icon-shower"),
"it has a the correct icon"
);
});
assert.ok(
this.get("subject")
.filter()
.icon()
.hasClass("d-icon-shower"),
"it has a the correct icon"
);
}
});
componentTest("is expandable", {
template: "{{single-select}}",
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() => assert.ok(this.get("subject").isExpanded()));
assert.ok(this.get("subject").isExpanded());
this.get("subject").collapse();
await this.get("subject").collapse();
andThen(() => assert.notOk(this.get("subject").isExpanded()));
assert.notOk(this.get("subject").isExpanded());
}
});
@ -164,17 +148,15 @@ componentTest("accepts custom value/name keys", {
this.set("content", [{ identifier: 1, item: "robin" }]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() => {
assert.equal(
this.get("subject")
.selectedRow()
.name(),
"robin"
);
});
assert.equal(
this.get("subject")
.selectedRow()
.name(),
"robin"
);
}
});
@ -185,14 +167,12 @@ componentTest("doesn’t render collection content before first expand", {
this.set("content", [{ value: 1, name: "robin" }]);
},
test(assert) {
async test(assert) {
assert.notOk(exists(find(".select-kit-collection")));
this.get("subject").expand();
await this.get("subject").expand();
andThen(() => {
assert.ok(exists(find(".select-kit-collection")));
});
assert.ok(exists(find(".select-kit-collection")));
}
});
@ -203,29 +183,25 @@ componentTest("dynamic headerText", {
this.set("content", [{ id: 1, name: "robin" }, { id: 2, name: "regis" }]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() => {
assert.equal(
this.get("subject")
.header()
.name(),
"robin"
);
});
assert.equal(
this.get("subject")
.header()
.name(),
"robin"
);
this.get("subject").selectRowByValue(2);
await this.get("subject").selectRowByValue(2);
andThen(() => {
assert.equal(
this.get("subject")
.header()
.name(),
"regis",
"it changes header text"
);
});
assert.equal(
this.get("subject")
.header()
.name(),
"regis",
"it changes header text"
);
}
});
@ -239,19 +215,17 @@ componentTest("supports custom row template", {
});
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() => {
assert.equal(
this.get("subject")
.rowByValue(1)
.el()
.html()
.trim(),
"<b>robin</b>"
);
});
assert.equal(
this.get("subject")
.rowByValue(1)
.el()
.html()
.trim(),
"<b>robin</b>"
);
}
});
@ -266,31 +240,25 @@ componentTest("supports converting select value to integer", {
]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() =>
assert.equal(
this.get("subject")
.selectedRow()
.name(),
"régis"
)
assert.equal(
this.get("subject")
.selectedRow()
.name(),
"régis"
);
andThen(() => {
this.set("value", 1);
});
await this.set("value", 1);
andThen(() => {
assert.equal(
this.get("subject")
.selectedRow()
.name(),
"robin",
"it works with dynamic content"
);
});
assert.equal(
this.get("subject")
.selectedRow()
.name(),
"robin",
"it works with dynamic content"
);
}
});
@ -305,31 +273,25 @@ componentTest("supports converting string as boolean to boolean", {
]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() =>
assert.equal(
this.get("subject")
.selectedRow()
.name(),
"ASC"
)
assert.equal(
this.get("subject")
.selectedRow()
.name(),
"ASC"
);
andThen(() => {
this.set("value", false);
});
await this.set("value", false);
andThen(() => {
assert.equal(
this.get("subject")
.selectedRow()
.name(),
"DESC",
"it works with dynamic content"
);
});
assert.equal(
this.get("subject")
.selectedRow()
.name(),
"DESC",
"it works with dynamic content"
);
}
});
@ -340,92 +302,68 @@ componentTest("supports keyboard events", {
this.set("content", [{ id: 1, name: "robin" }, { id: 2, name: "regis" }]);
},
test(assert) {
this.get("subject")
.expand()
.keyboard()
.down();
async test(assert) {
await this.get("subject").expand();
await this.get("subject").keyboard("down");
andThen(() => {
assert.equal(
this.get("subject")
.highlightedRow()
.title(),
"regis",
"the next row is highlighted"
);
});
assert.equal(
this.get("subject")
.highlightedRow()
.title(),
"regis",
"the next row is highlighted"
);
this.get("subject")
.keyboard()
.down();
await this.get("subject").keyboard("down");
andThen(() => {
assert.equal(
this.get("subject")
.highlightedRow()
.title(),
"robin",
"it returns to the first row"
);
});
assert.equal(
this.get("subject")
.highlightedRow()
.title(),
"robin",
"it returns to the first row"
);
this.get("subject")
.keyboard()
.up();
await this.get("subject").keyboard("up");
andThen(() => {
assert.equal(
this.get("subject")
.highlightedRow()
.title(),
"regis",
"it highlights the last row"
);
});
assert.equal(
this.get("subject")
.highlightedRow()
.title(),
"regis",
"it highlights the last row"
);
this.get("subject")
.keyboard()
.enter();
await this.get("subject").keyboard("enter");
andThen(() => {
assert.equal(
this.get("subject")
.selectedRow()
.title(),
"regis",
"it selects the row when pressing enter"
);
assert.notOk(
this.get("subject").isExpanded(),
"it collapses the select box when selecting a row"
);
});
assert.equal(
this.get("subject")
.selectedRow()
.title(),
"regis",
"it selects the row when pressing enter"
);
assert.notOk(
this.get("subject").isExpanded(),
"it collapses the select box when selecting a row"
);
this.get("subject")
.expand()
.keyboard()
.escape();
await this.get("subject").expand();
await this.get("subject").keyboard("escape");
andThen(() => {
assert.notOk(
this.get("subject").isExpanded(),
"it collapses the select box"
);
});
assert.notOk(
this.get("subject").isExpanded(),
"it collapses the select box"
);
this.get("subject")
.expand()
.fillInFilter("regis")
.keyboard()
.tab();
await this.get("subject").expand();
await this.get("subject").fillInFilter("regis");
await this.get("subject").keyboard("tab");
andThen(() => {
assert.notOk(
this.get("subject").isExpanded(),
"it collapses the select box when selecting a row"
);
});
assert.notOk(
this.get("subject").isExpanded(),
"it collapses the select box when selecting a row"
);
}
});
@ -442,13 +380,11 @@ componentTest("with allowInitialValueMutation", {
},
test(assert) {
andThen(() => {
assert.equal(
this.get("value"),
"1",
"it mutates the value on initial rendering"
);
});
assert.equal(
this.get("value"),
"1",
"it mutates the value on initial rendering"
);
}
});
@ -464,20 +400,18 @@ componentTest("support appending content through plugin api", {
this.set("content", [{ id: "1", name: "robin" }]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() => {
assert.equal(this.get("subject").rows().length, 2);
assert.equal(
this.get("subject")
.rowByIndex(1)
.name(),
"regis"
);
});
assert.equal(this.get("subject").rows().length, 2);
assert.equal(
this.get("subject")
.rowByIndex(1)
.name(),
"regis"
);
andThen(() => clearCallbacks());
clearCallbacks();
}
});
@ -500,20 +434,18 @@ componentTest("support modifying content through plugin api", {
]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() => {
assert.equal(this.get("subject").rows().length, 3);
assert.equal(
this.get("subject")
.rowByIndex(1)
.name(),
"sam"
);
});
assert.equal(this.get("subject").rows().length, 3);
assert.equal(
this.get("subject")
.rowByIndex(1)
.name(),
"sam"
);
andThen(() => clearCallbacks());
clearCallbacks();
}
});
@ -530,20 +462,18 @@ componentTest("support prepending content through plugin api", {
this.set("content", [{ id: "1", name: "robin" }]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() => {
assert.equal(this.get("subject").rows().length, 2);
assert.equal(
this.get("subject")
.rowByIndex(0)
.name(),
"regis"
);
});
assert.equal(this.get("subject").rows().length, 2);
assert.equal(
this.get("subject")
.rowByIndex(0)
.name(),
"regis"
);
andThen(() => clearCallbacks());
clearCallbacks();
}
});
@ -561,16 +491,13 @@ componentTest("support modifying on select behavior through plugin api", {
this.set("content", [{ id: "1", name: "robin" }]);
},
test(assert) {
this.get("subject")
.expand()
.selectRowByValue(1);
async test(assert) {
await this.get("subject").expand();
await this.get("subject").selectRowByValue(1);
andThen(() => {
assert.equal(find(".on-select-test").html(), "1");
});
assert.equal(find(".on-select-test").html(), "1");
andThen(() => clearCallbacks());
clearCallbacks();
}
});
@ -582,30 +509,24 @@ componentTest("with nameChanges", {
this.set("content", [this.get("robin")]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() => {
assert.equal(
this.get("subject")
.header()
.name(),
"robin"
);
});
assert.equal(
this.get("subject")
.header()
.name(),
"robin"
);
andThen(() => {
this.set("robin.name", "robin2");
});
await this.set("robin.name", "robin2");
andThen(() => {
assert.equal(
this.get("subject")
.header()
.name(),
"robin2"
);
});
assert.equal(
this.get("subject")
.header()
.name(),
"robin2"
);
}
});
@ -616,23 +537,21 @@ componentTest("with null value", {
this.set("content", [{ name: "robin" }]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() => {
assert.equal(
this.get("subject")
.header()
.name(),
"robin"
);
assert.equal(
this.get("subject")
.header()
.value(),
undefined
);
});
assert.equal(
this.get("subject")
.header()
.name(),
"robin"
);
assert.equal(
this.get("subject")
.header()
.value(),
undefined
);
}
});
@ -643,10 +562,10 @@ componentTest("with collection header", {
this.set("collectionHeader", "<h2>Hello</h2>");
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() => assert.ok(exists(".collection-header h2")));
assert.ok(exists(".collection-header h2"));
}
});
@ -658,13 +577,11 @@ componentTest("with title", {
},
test(assert) {
andThen(() =>
assert.equal(
this.get("subject")
.header()
.title(),
"My title"
)
assert.equal(
this.get("subject")
.header()
.title(),
"My title"
);
}
});
@ -686,16 +603,14 @@ componentTest("support modifying header computed content through plugin api", {
},
test(assert) {
andThen(() => {
assert.equal(
this.get("subject")
.header()
.title(),
"Not so evil"
);
});
assert.equal(
this.get("subject")
.header()
.title(),
"Not so evil"
);
andThen(() => clearCallbacks());
clearCallbacks();
}
});
@ -706,16 +621,14 @@ componentTest("with limitMatches", {
this.set("content", ["sam", "jeff", "neil"]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() =>
assert.equal(
this.get("subject")
.el()
.find(".select-kit-row").length,
2
)
assert.equal(
this.get("subject")
.el()
.find(".select-kit-row").length,
2
);
}
});
@ -728,26 +641,22 @@ componentTest("with minimum", {
this.set("content", ["sam", "jeff", "neil"]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() =>
assert.equal(
this.get("subject").validationMessage(),
"Select at least 1 item."
)
assert.equal(
this.get("subject").validationMessage(),
"Select at least 1 item."
);
this.get("subject").selectRowByValue("sam");
await this.get("subject").selectRowByValue("sam");
andThen(() => {
assert.equal(
this.get("subject")
.header()
.label(),
"sam"
);
});
assert.equal(
this.get("subject")
.header()
.label(),
"sam"
);
}
});
@ -760,23 +669,19 @@ componentTest("with minimumLabel", {
this.set("content", ["sam", "jeff", "neil"]);
},
test(assert) {
this.get("subject").expand();
async test(assert) {
await this.get("subject").expand();
andThen(() =>
assert.equal(this.get("subject").validationMessage(), "min 1")
assert.equal(this.get("subject").validationMessage(), "min 1");
await this.get("subject").selectRowByValue("jeff");
assert.equal(
this.get("subject")
.header()
.label(),
"jeff"
);
this.get("subject").selectRowByValue("jeff");
andThen(() => {
assert.equal(
this.get("subject")
.header()
.label(),
"jeff"
);
});
}
});
@ -787,19 +692,17 @@ componentTest("with accents in filter", {
this.set("content", ["sam", "jeff", "neil"]);
},
test(assert) {
this.get("subject").expand();
this.get("subject").fillInFilter("jéff");
async test(assert) {
await this.get("subject").expand();
await this.get("subject").fillInFilter("jéff");
andThen(() => {
assert.equal(this.get("subject").rows().length, 1);
assert.equal(
this.get("subject")
.rowByIndex(0)
.name(),
"jeff"
);
});
assert.equal(this.get("subject").rows().length, 1);
assert.equal(
this.get("subject")
.rowByIndex(0)
.name(),
"jeff"
);
}
});
@ -810,18 +713,16 @@ componentTest("with accents in content", {
this.set("content", ["sam", "jéff", "neil"]);
},
test(assert) {
this.get("subject").expand();
this.get("subject").fillInFilter("jeff");
async test(assert) {
await this.get("subject").expand();
await this.get("subject").fillInFilter("jeff");
andThen(() => {
assert.equal(this.get("subject").rows().length, 1);
assert.equal(
this.get("subject")
.rowByIndex(0)
.name(),
"jéff"
);
});
assert.equal(this.get("subject").rows().length, 1);
assert.equal(
this.get("subject")
.rowByIndex(0)
.name(),
"jéff"
);
}
});

View File

@ -22,7 +22,7 @@ componentTest("default", {
},
async test(assert) {
await this.get("subject").expandAwait();
await this.get("subject").expand();
assert.equal(
this.get("subject")
@ -55,7 +55,7 @@ componentTest("default", {
"it doesn’t preselect first row"
);
await this.get("subject").selectRowByValueAwait("share");
await this.get("subject").selectRowByValue("share");
assert.equal(this.get("value"), null, "it resets the value");
}

View File

@ -33,7 +33,7 @@ componentTest("regular topic notification level descriptions", {
"{{topic-notifications-options value=topic.details.notification_level topic=topic}}",
async test(assert) {
await selectKit().expandAwait();
await selectKit().expand();
await this.set("topic", buildTopic("regular"));
const uiTexts = extractDescs(selectKit().rows());
@ -59,7 +59,7 @@ componentTest("PM topic notification level descriptions", {
"{{topic-notifications-options value=topic.details.notification_level topic=topic}}",
async test(assert) {
await selectKit().expandAwait();
await selectKit().expand();
await this.set("topic", buildTopic("private_message"));
const uiTexts = extractDescs(selectKit().rows());

View File

@ -0,0 +1,15 @@
Ember.Test.registerAsyncHelper("formatTextWithSelection", function(
app,
text,
[start, len]
) {
return [
'"',
text.substr(0, start),
"<",
text.substr(start, len),
">",
text.substr(start + len),
'"'
].join("");
});

View File

@ -68,6 +68,47 @@ Ember.Test.registerAsyncHelper("selectKitSelectRowByIndex", function(
click(find(selector + " .select-kit-row").eq(index));
});
Ember.Test.registerAsyncHelper("keyboardHelper", function(
app,
value,
target,
selector
) {
function createEvent(element, keyCode, options) {
element = element || ".filter-input";
selector = find(selector).find(element);
options = options || {};
var type = options.type || "keydown";
var event = jQuery.Event(type);
event.keyCode = keyCode;
if (options && options.metaKey) {
event.metaKey = true;
}
andThen(() => {
find(selector).trigger(event);
});
}
switch (value) {
case "enter":
return createEvent(target, 13);
case "backspace":
return createEvent(target, 8);
case "selectAll":
return createEvent(target, 65, { metaKey: true });
case "escape":
return createEvent(target, 27);
case "down":
return createEvent(target, 40);
case "up":
return createEvent(target, 38);
case "tab":
return createEvent(target, 9);
}
});
// eslint-disable-next-line no-unused-vars
function selectKit(selector) {
selector = selector || ".select-kit";
@ -132,65 +173,13 @@ function selectKit(selector) {
};
}
function keyboardHelper(eventSelector) {
function createEvent(target, keyCode, options) {
target = target || ".filter-input";
eventSelector = find(eventSelector).find(target);
options = options || {};
andThen(function() {
var type = options.type || "keydown";
var event = jQuery.Event(type);
event.keyCode = keyCode;
if (options && options.metaKey) {
event.metaKey = true;
}
find(eventSelector).trigger(event);
});
}
return {
down: function(target) {
createEvent(target, 40);
},
up: function(target) {
createEvent(target, 38);
},
escape: function(target) {
createEvent(target, 27);
},
enter: function(target) {
createEvent(target, 13);
},
tab: function(target) {
createEvent(target, 9);
},
backspace: function(target) {
createEvent(target, 8);
},
selectAll: function(target) {
createEvent(target, 65, { metaKey: true });
}
};
}
return {
expandAwait: function() {
expand: function() {
return expandSelectKit(selector);
},
expand: function() {
expandSelectKit(selector);
return selectKit(selector);
},
collapseAwait: function() {
return collapseSelectKit(selector);
},
collapse: function() {
collapseSelectKit(selector);
return selectKit(selector);
return collapseSelectKit(selector);
},
selectRowByIndex: function(index) {
@ -198,13 +187,8 @@ function selectKit(selector) {
return selectKit(selector);
},
selectRowByValueAwait: function(value) {
return selectKitSelectRowByValue(value, selector);
},
selectRowByValue: function(value) {
selectKitSelectRowByValue(value, selector);
return selectKit(selector);
return selectKitSelectRowByValue(value, selector);
},
selectRowByName: function(name) {
@ -213,25 +197,15 @@ function selectKit(selector) {
},
selectNoneRow: function() {
selectKitSelectNoneRow(selector);
return selectKit(selector);
},
selectNoneRowAwait: function() {
return selectKitSelectNoneRow(selector);
},
fillInFilter: function(filter) {
selectKitFillInFilter(filter, selector);
return selectKit(selector);
},
fillInFilterAwait: function(filter) {
return selectKitFillInFilter(filter, selector);
},
keyboard: function() {
return keyboardHelper(selector);
keyboard: function(value, target) {
return keyboardHelper(value, target, selector);
},
isExpanded: function() {

View File

@ -33,6 +33,7 @@
//= require helpers/assertions
//= require helpers/select-kit-helper
//= require helpers/d-editor-helper
//= require helpers/qunit-helpers
//= require_tree ./fixtures