tests: Use async/await instead of returning Promises

This has a few benefits:
  * It's more readable: It's easier for a user of the function to know
    that they should use `await` when calling the function.
  * Stack traces are more useful.
  * Some code (e.g., the async npm package) uses introspection to
    determine if a function is `async` vs. takes a callback.
This commit is contained in:
Richard Hansen 2021-03-31 17:16:19 -04:00 committed by webzwo0i
parent b164a34e64
commit 3790c0e41c
2 changed files with 20 additions and 20 deletions

View file

@ -13,11 +13,11 @@ helper.contentWindow = () => $('#iframe-container iframe')[0].contentWindow;
*
* @returns {Promise}
*/
helper.showChat = () => {
helper.showChat = async () => {
const chaticon = helper.chatIcon();
if (!chaticon.hasClass('visible')) return;
chaticon.click();
return helper.waitForPromise(() => !chaticon.hasClass('visible'), 2000);
await helper.waitForPromise(() => !chaticon.hasClass('visible'), 2000);
};
/**
@ -25,10 +25,10 @@ helper.showChat = () => {
*
* @returns {Promise}
*/
helper.hideChat = () => {
helper.hideChat = async () => {
if (!helper.isChatboxShown() || helper.isChatboxSticky()) return;
helper.titlecross().click();
return helper.waitForPromise(() => !helper.isChatboxShown(), 2000);
await helper.waitForPromise(() => !helper.isChatboxShown(), 2000);
};
/**