tests: Asyncify indentation test

This makes it much easier to see why a test is failing. Before, a
`helper.waitFor()` failure would simply cause the test to time out.
Now an exception is displayed.
pull/4601/head
Richard Hansen 2021-01-29 03:05:08 -05:00 committed by John McLear
parent 462530eafb
commit 873987f989
1 changed files with 24 additions and 26 deletions

View File

@ -130,41 +130,39 @@ describe('indentation button', function () {
}); });
}); });
it("issue #2772 shows '*' when multiple indented lines receive a style and are outdented", function (done) { it("issue #2772 shows '*' when multiple indented lines receive a style and are outdented", async function () {
const inner$ = helper.padInner$; const inner$ = helper.padInner$;
const chrome$ = helper.padChrome$; const chrome$ = helper.padChrome$;
// make sure pad has more than one line // make sure pad has more than one line
inner$('div').first().sendkeys('First{enter}Second{enter}'); inner$('div').first().sendkeys('First{enter}Second{enter}');
helper.waitFor(() => inner$('div').first().text().trim() === 'First').done(() => { await helper.waitForPromise(() => inner$('div').first().text().trim() === 'First');
// indent first 2 lines // indent first 2 lines
const $lines = inner$('div'); const $lines = inner$('div');
const $firstLine = $lines.first(); const $firstLine = $lines.first();
const $secondLine = $lines.slice(1, 2); let $secondLine = $lines.slice(1, 2);
helper.selectLines($firstLine, $secondLine); helper.selectLines($firstLine, $secondLine);
const $indentButton = chrome$('.buttonicon-indent'); const $indentButton = chrome$('.buttonicon-indent');
$indentButton.click(); $indentButton.click();
helper.waitFor(() => inner$('div').first().find('ul li').length === 1).done(() => { await helper.waitForPromise(() => inner$('div').first().find('ul li').length === 1);
// apply bold // apply bold
const $boldButton = chrome$('.buttonicon-bold'); const $boldButton = chrome$('.buttonicon-bold');
$boldButton.click(); $boldButton.click();
helper.waitFor(() => inner$('div').first().find('b').length === 1).done(() => { await helper.waitForPromise(() => inner$('div').first().find('b').length === 1);
// outdent first 2 lines // outdent first 2 lines
const $outdentButton = chrome$('.buttonicon-outdent'); const $outdentButton = chrome$('.buttonicon-outdent');
$outdentButton.click(); $outdentButton.click();
helper.waitFor(() => inner$('div').first().find('ul li').length === 0).done(() => { await helper.waitForPromise(() => inner$('div').first().find('ul li').length === 0);
// check if '*' is displayed
const $secondLine = inner$('div').slice(1, 2);
expect($secondLine.text().trim()).to.be('Second');
done(); // check if '*' is displayed
}); $secondLine = inner$('div').slice(1, 2);
}); expect($secondLine.text().trim()).to.be('Second');
});
});
}); });
/* /*