DEV: Use async functions in tests (#9087)

This change both improves readability and fixes potential race-condition issues where promises were nested instead of being chained.

Also includes:
* Use arrow functions and Promise shorthands
* Remove the obsolete `asyncTestDiscourse` helper
This commit is contained in:
Jarek Radosz
2020-03-02 21:20:19 +01:00
committed by GitHub
parent 537f87562e
commit 4da357e378
10 changed files with 241 additions and 318 deletions

View File

@@ -1,6 +1,6 @@
moduleFor("controller:history");
QUnit.test("displayEdit", function(assert) {
QUnit.test("displayEdit", async function(assert) {
const HistoryController = this.subject();
HistoryController.setProperties({
@@ -82,8 +82,8 @@ QUnit.test("displayEdit", function(assert) {
}
});
HistoryController.bodyDiffChanged().then(() => {
const output = HistoryController.get("bodyDiff");
assert.equal(output, expectedOutput, "it keeps safe HTML");
});
await HistoryController.bodyDiffChanged();
const output = HistoryController.get("bodyDiff");
assert.equal(output, expectedOutput, "it keeps safe HTML");
});