Skip to content

A platform for community discussion. Free, open, simple.

DEV: migrate widgets tests to async/await

Maja Komel3a52c2fa64b0
diff --git a/test/javascripts/widgets/actions-summary-test.js.es6 b/test/javascripts/widgets/actions-summary-test.js.es6
index 2a6fbbd3448..407200feeda 100644
--- a/test/javascripts/widgets/actions-summary-test.js.es6
+++ b/test/javascripts/widgets/actions-summary-test.js.es6
@@ -12,17 +12,15 @@ widgetTest("listing actions", {
]
});
},
- test(assert) {
+ async test(assert) {
assert.equal(this.$(".post-actions .post-action").length, 2);
- click(".post-action:eq(0) .action-link a");
- andThen(() => {
- assert.equal(
- this.$(".post-action:eq(0) img.avatar").length,
- 1,
- "clicking it shows the user"
- );
- });
+ await click(".post-action:eq(0) .action-link a");
+ assert.equal(
+ this.$(".post-action:eq(0) img.avatar").length,
+ 1,
+ "clicking it shows the user"
+ );
}
});
@@ -38,13 +36,11 @@ widgetTest("undo", {
this.set("undoPostAction", () => (this.undid = true));
},
- test(assert) {
+ async test(assert) {
assert.equal(this.$(".post-actions .post-action").length, 1);
- click(".action-link.undo");
- andThen(() => {
- assert.ok(this.undid, "it triggered the action");
- });
+ await click(".action-link.undo");
+ assert.ok(this.undid, "it triggered the action");
}
});
@@ -65,13 +61,11 @@ widgetTest("deferFlags", {
this.on("deferPostActionFlags", () => (this.deferred = true));
},
- test(assert) {
+ async test(assert) {
assert.equal(this.$(".post-actions .post-action").length, 1);
- click(".action-link.defer-flags");
- andThen(() => {
- assert.ok(this.deferred, "it triggered the action");
- });
+ await click(".action-link.defer-flags");
+ assert.ok(this.deferred, "it triggered the action");
}
});
diff --git a/test/javascripts/widgets/header-test.js.es6 b/test/javascripts/widgets/header-test.js.es6
index 7fdebfbb366..dc12a9e74fc 100644
--- a/test/javascripts/widgets/header-test.js.es6
+++ b/test/javascripts/widgets/header-test.js.es6
@@ -21,19 +21,15 @@ widgetTest("sign up / login buttons", {
this.on("showLogin", () => (this.loginShown = true));
},
- test(assert) {
+ async test(assert) {
assert.ok(this.$("button.sign-up-button").length);
assert.ok(this.$("button.login-button").length);
- click("button.sign-up-button");
- andThen(() => {
- assert.ok(this.signupShown);
- });
+ await click("button.sign-up-button");
+ assert.ok(this.signupShown);
- click("button.login-button");
- andThen(() => {
- assert.ok(this.loginShown);
- });
+ await click("button.login-button");
+ assert.ok(this.loginShown);
}
});
diff --git a/test/javascripts/widgets/post-links-test.js.es6 b/test/javascripts/widgets/post-links-test.js.es6
index ed40a6fadbb..4dce86ea4b5 100644
--- a/test/javascripts/widgets/post-links-test.js.es6
+++ b/test/javascripts/widgets/post-links-test.js.es6
@@ -46,11 +46,9 @@ widgetTest("collapsed links", {
]
});
},
- test(assert) {
+ async test(assert) {
assert.ok(this.$(".expand-links").length === 1, "collapsed by default");
- click("a.expand-links");
- andThen(() => {
- assert.equal(this.$(".post-links a.track-link").length, 7);
- });
+ await click("a.expand-links");
+ assert.equal(this.$(".post-links a.track-link").length, 7);
}
});
diff --git a/test/javascripts/widgets/post-test.js.es6 b/test/javascripts/widgets/post-test.js.es6
index 7bd21c9342a..f01f7df534c 100644
--- a/test/javascripts/widgets/post-test.js.es6
+++ b/test/javascripts/widgets/post-test.js.es6
@@ -23,14 +23,12 @@ widgetTest("wiki", {
this.set("args", { wiki: true, version: 2, canViewEditHistory: true });
this.on("showHistory", () => (this.historyShown = true));
},
- test(assert) {
- click(".post-info .wiki");
- andThen(() => {
- assert.ok(
- this.historyShown,
- "clicking the wiki icon displays the post history"
- );
- });
+ async test(assert) {
+ await click(".post-info .wiki");
+ assert.ok(
+ this.historyShown,
+ "clicking the wiki icon displays the post history"
+ );
}
});
@@ -40,11 +38,9 @@ widgetTest("wiki without revision", {
this.set("args", { wiki: true, version: 1, canViewEditHistory: true });
this.on("editPost", () => (this.editPostCalled = true));
},
- test(assert) {
- click(".post-info .wiki");
- andThen(() => {
- assert.ok(this.editPostCalled, "clicking wiki icon edits the post");
- });
+ async test(assert) {
+ await click(".post-info .wiki");
+ assert.ok(this.editPostCalled, "clicking wiki icon edits the post");
}
});
@@ -55,14 +51,9 @@ widgetTest("via-email", {
this.set("args", { via_email: true, canViewRawEmail: true });
this.on("showRawEmail", () => (this.rawEmailShown = true));
},
- test(assert) {
- click(".post-info.via-email");
- andThen(() => {
- assert.ok(
- this.rawEmailShown,
- "clicking the enveloppe shows the raw email"
- );
- });
+ async test(assert) {
+ await click(".post-info.via-email");
+ assert.ok(this.rawEmailShown, "clicking the enveloppe shows the raw email");
}
});
@@ -73,14 +64,12 @@ widgetTest("via-email without permission", {
this.set("args", { via_email: true, canViewRawEmail: false });
this.on("showRawEmail", () => (this.rawEmailShown = true));
},
- test(assert) {
- click(".post-info.via-email");
- andThen(() => {
- assert.ok(
- !this.rawEmailShown,
- `clicking the enveloppe doesn't show the raw email`
- );
- });
+ async test(assert) {
+ await click(".post-info.via-email");
+ assert.ok(
+ !this.rawEmailShown,
+ `clicking the enveloppe doesn't show the raw email`
+ );
}
});
@@ -91,11 +80,9 @@ widgetTest("history", {
this.set("args", { version: 3, canViewEditHistory: true });
this.on("showHistory", () => (this.historyShown = true));
},
- test(assert) {
- click(".post-info.edits");
- andThen(() => {
- assert.ok(this.historyShown, "clicking the pencil shows the history");
- });
+ async test(assert) {
+ await click(".post-info.edits");
+ assert.ok(this.historyShown, "clicking the pencil shows the history");
}
});
@@ -106,14 +93,12 @@ widgetTest("history without view permission", {
this.set("args", { version: 3, canViewEditHistory: false });
this.on("showHistory", () => (this.historyShown = true));
},
- test(assert) {
- click(".post-info.edits");
- andThen(() => {
- assert.ok(
- !this.historyShown,
- `clicking the pencil doesn't show the history`
- );
- });
+ async test(assert) {
+ await click(".post-info.edits");
+ assert.ok(
+ !this.historyShown,
+ `clicking the pencil doesn't show the history`
+ );
}
});
@@ -142,23 +127,19 @@ widgetTest("like count button", {
this.set("post", post);
this.set("args", { likeCount: 1 });
},
- test(assert) {
+ async test(assert) {
assert.ok(this.$("button.like-count").length === 1);
assert.ok(this.$(".who-liked").length === 0);
// toggle it on
- click("button.like-count");
- andThen(() => {
- assert.ok(this.$(".who-liked").length === 1);
- assert.ok(this.$(".who-liked a.trigger-user-card").length === 1);
- });
+ await click("button.like-count");
+ assert.ok(this.$(".who-liked").length === 1);
+ assert.ok(this.$(".who-liked a.trigger-user-card").length === 1);
// toggle it off
- click("button.like-count");
- andThen(() => {
- assert.ok(this.$(".who-liked").length === 0);
- assert.ok(this.$(".who-liked a.trigger-user-card").length === 0);
- });
+ await click("button.like-count");
+ assert.ok(this.$(".who-liked").length === 0);
+ assert.ok(this.$(".who-liked a.trigger-user-card").length === 0);
}
});
@@ -196,23 +177,19 @@ widgetTest("liking", {
args.likeCount = args.liked ? 1 : 0;
});
},
- test(assert) {
+ async test(assert) {
assert.ok(!!this.$(".actions button.like").length);
assert.ok(this.$(".actions button.like-count").length === 0);
- click(".actions button.like");
- andThen(() => {
- assert.ok(!this.$(".actions button.like").length);
- assert.ok(!!this.$(".actions button.has-like").length);
- assert.ok(this.$(".actions button.like-count").length === 1);
- });
+ await click(".actions button.like");
+ assert.ok(!this.$(".actions button.like").length);
+ assert.ok(!!this.$(".actions button.has-like").length);
+ assert.ok(this.$(".actions button.like-count").length === 1);
- click(".actions button.has-like");
- andThen(() => {
- assert.ok(!!this.$(".actions button.like").length);
- assert.ok(!this.$(".actions button.has-like").length);
- assert.ok(this.$(".actions button.like-count").length === 0);
- });
+ await click(".actions button.has-like");
+ assert.ok(!!this.$(".actions button.like").length);
+ assert.ok(!this.$(".actions button.has-like").length);
+ assert.ok(this.$(".actions button.like-count").length === 0);
}
});
@@ -225,14 +202,12 @@ widgetTest("anon liking", {
this.set("args", args);
this.on("showLogin", () => (this.loginShown = true));
},
- test(assert) {
+ async test(assert) {
assert.ok(!!this.$(".actions button.like").length);
assert.ok(this.$(".actions button.like-count").length === 0);
- click(".actions button.like");
- andThen(() => {
- assert.ok(this.loginShown);
- });
+ await click(".actions button.like");
+ assert.ok(this.loginShown);
}
});
@@ -242,11 +217,9 @@ widgetTest("edit button", {
this.set("args", { canEdit: true });
this.on("editPost", () => (this.editPostCalled = true));
},
- test(assert) {
- click("button.edit");
- andThen(() => {
- assert.ok(this.editPostCalled, "it triggered the edit action");
- });
+ async test(assert) {
+ await click("button.edit");
+ assert.ok(this.editPostCalled, "it triggered the edit action");
}
});
@@ -266,11 +239,9 @@ widgetTest("recover button", {
this.set("args", { canDelete: true });
this.on("deletePost", () => (this.deletePostCalled = true));
},
- test(assert) {
- click("button.delete");
- andThen(() => {
- assert.ok(this.deletePostCalled, "it triggered the delete action");
- });
+ async test(assert) {
+ await click("button.delete");
+ assert.ok(this.deletePostCalled, "it triggered the delete action");
}
});
@@ -280,11 +251,9 @@ widgetTest("delete topic button", {
this.set("args", { canDeleteTopic: true });
this.on("deletePost", () => (this.deletePostCalled = true));
},
- test(assert) {
- click("button.delete");
- andThen(() => {
- assert.ok(this.deletePostCalled, "it triggered the delete action");
- });
+ async test(assert) {
+ await click("button.delete");
+ assert.ok(this.deletePostCalled, "it triggered the delete action");
}
});
@@ -329,9 +298,9 @@ widgetTest("recover topic button", {
this.set("args", { canRecoverTopic: true });
this.on("recoverPost", () => (this.recovered = true));
},
- test(assert) {
- click("button.recover");
- andThen(() => assert.ok(this.recovered));
+ async test(assert) {
+ await click("button.recover");
+ assert.ok(this.recovered);
}
});
@@ -351,11 +320,9 @@ widgetTest("delete post button", {
this.set("args", { canDelete: true });
this.on("deletePost", () => (this.deletePostCalled = true));
},
- test(assert) {
- click("button.delete");
- andThen(() => {
- assert.ok(this.deletePostCalled, "it triggered the delete action");
- });
+ async test(assert) {
+ await click("button.delete");
+ assert.ok(this.deletePostCalled, "it triggered the delete action");
}
});
@@ -376,9 +343,9 @@ widgetTest("recover post button", {
this.set("args", { canRecover: true });
this.on("recoverPost", () => (this.recovered = true));
},
- test(assert) {
- click("button.recover");
- andThen(() => assert.ok(this.recovered));
+ async test(assert) {
+ await click("button.recover");
+ assert.ok(this.recovered);
}
});
@@ -398,13 +365,11 @@ widgetTest(`flagging`, {
this.set("args", { canFlag: true });
this.on("showFlags", () => (this.flagsShown = true));
},
- test(assert) {
+ async test(assert) {
assert.ok(this.$("button.create-flag").length === 1);
- click("button.create-flag");
- andThen(() => {
- assert.ok(this.flagsShown, "it triggered the action");
- });
+ await click("button.create-flag");
+ assert.ok(this.flagsShown, "it triggered the action");
}
});
@@ -482,13 +447,11 @@ widgetTest("reply directly above", {
});
this.siteSettings.suppress_reply_directly_above = false;
},
- test(assert) {
+ async test(assert) {
assert.equal(this.$(".avoid-tab").length, 1, "has the avoid tab class");
- click("a.reply-to-tab");
- andThen(() => {
- assert.equal(this.$("section.embedded-posts.top .cooked").length, 1);
- assert.equal(this.$("section.embedded-posts .d-icon-arrow-up").length, 1);
- });
+ await click("a.reply-to-tab");
+ assert.equal(this.$("section.embedded-posts.top .cooked").length, 1);
+ assert.equal(this.$("section.embedded-posts .d-icon-arrow-up").length, 1);
}
});
@@ -499,11 +462,9 @@ widgetTest("cooked content hidden", {
this.set("args", { cooked_hidden: true });
this.on("expandHidden", () => (this.unhidden = true));
},
- test(assert) {
- click(".topic-body .expand-hidden");
- andThen(() => {
- assert.ok(this.unhidden, "triggers the action");
- });
+ async test(assert) {
+ await click(".topic-body .expand-hidden");
+ assert.ok(this.unhidden, "triggers the action");
}
});
@@ -513,11 +474,9 @@ widgetTest("expand first post", {
this.set("args", { expandablePost: true });
this.set("post", store.createRecord("post", { id: 1234 }));
},
- test(assert) {
- click(".topic-body .expand-post");
- andThen(() => {
- assert.equal(this.$(".expand-post").length, 0, "button is gone");
- });
+ async test(assert) {
+ await click(".topic-body .expand-post");
+ assert.equal(this.$(".expand-post").length, 0, "button is gone");
}
});
@@ -541,14 +500,12 @@ widgetTest("bookmark", {
this.set("args", args);
this.on("toggleBookmark", () => (args.bookmarked = true));
},
- test(assert) {
+ async test(assert) {
assert.equal(this.$(".post-menu-area .bookmark").length, 1);
assert.equal(this.$("button.bookmarked").length, 0);
- click("button.bookmark");
- andThen(() => {
- assert.equal(this.$("button.bookmarked").length, 1);
- });
+ await click("button.bookmark");
+ assert.equal(this.$("button.bookmarked").length, 1);
}
});
@@ -567,20 +524,16 @@ widgetTest("show admin menu", {
beforeEach() {
this.set("args", { canManage: true });
},
- test(assert) {
+ async test(assert) {
assert.equal(this.$(".post-admin-menu").length, 0);
- click(".post-menu-area .show-post-admin-menu");
- andThen(() => {
- assert.equal(this.$(".post-admin-menu").length, 1, "it shows the popup");
- });
- click(".post-menu-area");
- andThen(() => {
- assert.equal(
- this.$(".post-admin-menu").length,
- 0,
- "clicking outside clears the popup"
- );
- });
+ await click(".post-menu-area .show-post-admin-menu");
+ assert.equal(this.$(".post-admin-menu").length, 1, "it shows the popup");
+ await click(".post-menu-area");
+ assert.equal(
+ this.$(".post-admin-menu").length,
+ 0,
+ "clicking outside clears the popup"
+ );
}
});
@@ -591,13 +544,11 @@ widgetTest("toggle moderator post", {
this.set("args", { canManage: true });
this.on("togglePostType", () => (this.toggled = true));
},
- test(assert) {
- click(".post-menu-area .show-post-admin-menu");
- click(".post-admin-menu .toggle-post-type");
- andThen(() => {
- assert.ok(this.toggled);
- assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
- });
+ async test(assert) {
+ await click(".post-menu-area .show-post-admin-menu");
+ await click(".post-admin-menu .toggle-post-type");
+ assert.ok(this.toggled);
+ assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
}
});
widgetTest("toggle moderator post", {
@@ -607,13 +558,11 @@ widgetTest("toggle moderator post", {
this.set("args", { canManage: true });
this.on("togglePostType", () => (this.toggled = true));
},
- test(assert) {
- click(".post-menu-area .show-post-admin-menu");
- click(".post-admin-menu .toggle-post-type");
- andThen(() => {
- assert.ok(this.toggled);
- assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
- });
+ async test(assert) {
+ await click(".post-menu-area .show-post-admin-menu");
+ await click(".post-admin-menu .toggle-post-type");
+ assert.ok(this.toggled);
+ assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
}
});
@@ -623,13 +572,11 @@ widgetTest("rebake post", {
this.set("args", { canManage: true });
this.on("rebakePost", () => (this.baked = true));
},
- test(assert) {
- click(".post-menu-area .show-post-admin-menu");
- click(".post-admin-menu .rebuild-html");
- andThen(() => {
- assert.ok(this.baked);
- assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
- });
+ async test(assert) {
+ await click(".post-menu-area .show-post-admin-menu");
+ await click(".post-admin-menu .rebuild-html");
+ assert.ok(this.baked);
+ assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
}
});
@@ -639,13 +586,11 @@ widgetTest("unhide post", {
this.set("args", { canManage: true, hidden: true });
this.on("unhidePost", () => (this.unhidden = true));
},
- test(assert) {
- click(".post-menu-area .show-post-admin-menu");
- click(".post-admin-menu .unhide-post");
- andThen(() => {
- assert.ok(this.unhidden);
- assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
- });
+ async test(assert) {
+ await click(".post-menu-area .show-post-admin-menu");
+ await click(".post-admin-menu .unhide-post");
+ assert.ok(this.unhidden);
+ assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
}
});
@@ -657,13 +602,11 @@ widgetTest("change owner", {
this.set("args", { canManage: true });
this.on("changePostOwner", () => (this.owned = true));
},
- test(assert) {
- click(".post-menu-area .show-post-admin-menu");
- click(".post-admin-menu .change-owner");
- andThen(() => {
- assert.ok(this.owned);
- assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
- });
+ async test(assert) {
+ await click(".post-menu-area .show-post-admin-menu");
+ await click(".post-admin-menu .change-owner");
+ assert.ok(this.owned);
+ assert.equal(this.$(".post-admin-menu").length, 0, "also hides the menu");
}
});
@@ -674,11 +617,9 @@ widgetTest("reply", {
this.set("args", { canCreatePost: true });
this.on("replyToPost", () => (this.replied = true));
},
- test(assert) {
- click(".post-controls .create");
- andThen(() => {
- assert.ok(this.replied);
- });
+ async test(assert) {
+ await click(".post-controls .create");
+ assert.ok(this.replied);
}
});
@@ -730,15 +671,10 @@ widgetTest("replies - one below, not suppressed", {
this.siteSettings.suppress_reply_directly_below = false;
this.set("args", { id: 6654, replyCount: 1, replyDirectlyBelow: true });
},
- test(assert) {
- click("button.show-replies");
- andThen(() => {
- assert.equal(this.$("section.embedded-posts.bottom .cooked").length, 1);
- assert.equal(
- this.$("section.embedded-posts .d-icon-arrow-down").length,
- 1
- );
- });
+ async test(assert) {
+ await click("button.show-replies");
+ assert.equal(this.$("section.embedded-posts.bottom .cooked").length, 1);
+ assert.equal(this.$("section.embedded-posts .d-icon-arrow-down").length, 1);
}
});
@@ -761,21 +697,19 @@ widgetTest("topic map - few posts", {
participants: [{ username: "eviltrout" }, { username: "codinghorror" }]
});
},
- test(assert) {
+ async test(assert) {
assert.equal(
this.$("li.avatars a.poster").length,
0,
"shows no participants when collapsed"
);
- click("nav.buttons button");
- andThen(() => {
- assert.equal(
- this.$(".topic-map-expanded a.poster").length,
- 2,
- "shows all when expanded"
- );
- });
+ await click("nav.buttons button");
+ assert.equal(
+ this.$(".topic-map-expanded a.poster").length,
+ 2,
+ "shows all when expanded"
+ );
}
});
@@ -794,23 +728,21 @@ widgetTest("topic map - participants", {
userFilters: ["sam", "codinghorror"]
});
},
- test(assert) {
+ async test(assert) {
assert.equal(
this.$("li.avatars a.poster").length,
3,
"limits to three participants"
);
- click("nav.buttons button");
- andThen(() => {
- assert.equal(this.$("li.avatars a.poster").length, 0);
- assert.equal(
- this.$(".topic-map-expanded a.poster").length,
- 4,
- "shows all when expanded"
- );
- assert.equal(this.$("a.poster.toggled").length, 2, "two are toggled");
- });
+ await click("nav.buttons button");
+ assert.equal(this.$("li.avatars a.poster").length, 0);
+ assert.equal(
+ this.$(".topic-map-expanded a.poster").length,
+ 4,
+ "shows all when expanded"
+ );
+ assert.equal(this.$("a.poster.toggled").length, 2, "two are toggled");
}
});
@@ -829,31 +761,27 @@ widgetTest("topic map - links", {
]
});
},
- test(assert) {
+ async test(assert) {
assert.equal(this.$(".topic-map").length, 1);
assert.equal(this.$(".map.map-collapsed").length, 1);
assert.equal(this.$(".topic-map-expanded").length, 0);
- click("nav.buttons button");
- andThen(() => {
- assert.equal(this.$(".map.map-collapsed").length, 0);
- assert.equal(this.$(".topic-map .d-icon-chevron-up").length, 1);
- assert.equal(this.$(".topic-map-expanded").length, 1);
- assert.equal(
- this.$(".topic-map-expanded .topic-link").length,
- 5,
- "it limits the links displayed"
- );
- });
+ await click("nav.buttons button");
+ assert.equal(this.$(".map.map-collapsed").length, 0);
+ assert.equal(this.$(".topic-map .d-icon-chevron-up").length, 1);
+ assert.equal(this.$(".topic-map-expanded").length, 1);
+ assert.equal(
+ this.$(".topic-map-expanded .topic-link").length,
+ 5,
+ "it limits the links displayed"
+ );
- click(".link-summary button");
- andThen(() => {
- assert.equal(
- this.$(".topic-map-expanded .topic-link").length,
- 6,
- "all links now shown"
- );
- });
+ await click(".link-summary button");
+ assert.equal(
+ this.$(".topic-map-expanded .topic-link").length,
+ 6,
+ "all links now shown"
+ );
}
});
@@ -874,11 +802,11 @@ widgetTest("topic map - has summary", {
this.set("args", { showTopicMap: true, hasTopicSummary: true });
this.on("toggleSummary", () => (this.summaryToggled = true));
},
- test(assert) {
+ async test(assert) {
assert.equal(this.$(".toggle-summary").length, 1);
- click(".toggle-summary button");
- andThen(() => assert.ok(this.summaryToggled));
+ await click(".toggle-summary button");
+ assert.ok(this.summaryToggled);
}
});
diff --git a/test/javascripts/widgets/user-menu-test.js.es6 b/test/javascripts/widgets/user-menu-test.js.es6
index 951e0451859..b48dc952cec 100644
--- a/test/javascripts/widgets/user-menu-test.js.es6
+++ b/test/javascripts/widgets/user-menu-test.js.es6
@@ -22,13 +22,11 @@ widgetTest("log out", {
this.on("logout", () => (this.loggedOut = true));
},
- test(assert) {
+ async test(assert) {
assert.ok(this.$(".logout").length);
- click(".logout");
- andThen(() => {
- assert.ok(this.loggedOut);
- });
+ await click(".logout");
+ assert.ok(this.loggedOut);
}
});
@@ -66,12 +64,10 @@ widgetTest("anonymous", {
this.on("toggleAnonymous", () => (this.anonymous = true));
},
- test(assert) {
+ async test(assert) {
assert.ok(this.$(".enable-anonymous").length);
- click(".enable-anonymous");
- andThen(() => {
- assert.ok(this.anonymous);
- });
+ await click(".enable-anonymous");
+ assert.ok(this.anonymous);
}
});
@@ -98,11 +94,9 @@ widgetTest("anonymous - switch back", {
this.on("toggleAnonymous", () => (this.anonymous = true));
},
- test(assert) {
+ async test(assert) {
assert.ok(this.$(".disable-anonymous").length);
- click(".disable-anonymous");
- andThen(() => {
- assert.ok(this.anonymous);
- });
+ await click(".disable-anonymous");
+ assert.ok(this.anonymous);
}
});
diff --git a/test/javascripts/widgets/widget-test.js.es6 b/test/javascripts/widgets/widget-test.js.es6
index b8afd17cc5d..0b5eba78ea0 100644
--- a/test/javascripts/widgets/widget-test.js.es6
+++ b/test/javascripts/widgets/widget-test.js.es6
@@ -136,14 +136,12 @@ widgetTest("widget state", {
});
},
- test(assert) {
+ async test(assert) {
assert.ok(this.$("button.test").length, "it renders the button");
assert.equal(this.$("button.test").text(), "0 clicks");
- click(this.$("button"));
- andThen(() => {
- assert.equal(this.$("button.test").text(), "1 clicks");
- });
+ await click(this.$("button"));
+ assert.equal(this.$("button.test").text(), "1 clicks");
}
});
@@ -173,7 +171,7 @@ widgetTest("widget update with promise", {
});
},
- test(assert) {
+ async test(assert) {
assert.equal(
this.$("button.test")
.text()
@@ -181,15 +179,13 @@ widgetTest("widget update with promise", {
"No name"
);
- click(this.$("button"));
- andThen(() => {
- assert.equal(
- this.$("button.test")
- .text()
- .trim(),
- "Robin"
- );
- });
+ await click(this.$("button"));
+ assert.equal(
+ this.$("button.test")
+ .text()
+ .trim(),
+ "Robin"
+ );
}
});