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 chrome$ = helper.padChrome$;
// make sure pad has more than one line
inner$('div').first().sendkeys('First{enter}Second{enter}');
helper.waitFor(() => inner$('div').first().text().trim() === 'First').done(() => {
// indent first 2 lines
const $lines = inner$('div');
const $firstLine = $lines.first();
const $secondLine = $lines.slice(1, 2);
helper.selectLines($firstLine, $secondLine);
await helper.waitForPromise(() => inner$('div').first().text().trim() === 'First');
const $indentButton = chrome$('.buttonicon-indent');
$indentButton.click();
// indent first 2 lines
const $lines = inner$('div');
const $firstLine = $lines.first();
let $secondLine = $lines.slice(1, 2);
helper.selectLines($firstLine, $secondLine);
helper.waitFor(() => inner$('div').first().find('ul li').length === 1).done(() => {
// apply bold
const $boldButton = chrome$('.buttonicon-bold');
$boldButton.click();
const $indentButton = chrome$('.buttonicon-indent');
$indentButton.click();
helper.waitFor(() => inner$('div').first().find('b').length === 1).done(() => {
// outdent first 2 lines
const $outdentButton = chrome$('.buttonicon-outdent');
$outdentButton.click();
helper.waitFor(() => inner$('div').first().find('ul li').length === 0).done(() => {
// check if '*' is displayed
const $secondLine = inner$('div').slice(1, 2);
expect($secondLine.text().trim()).to.be('Second');
await helper.waitForPromise(() => inner$('div').first().find('ul li').length === 1);
done();
});
});
});
});
// apply bold
const $boldButton = chrome$('.buttonicon-bold');
$boldButton.click();
await helper.waitForPromise(() => inner$('div').first().find('b').length === 1);
// outdent first 2 lines
const $outdentButton = chrome$('.buttonicon-outdent');
$outdentButton.click();
await helper.waitForPromise(() => inner$('div').first().find('ul li').length === 0);
// check if '*' is displayed
$secondLine = inner$('div').slice(1, 2);
expect($secondLine.text().trim()).to.be('Second');
});
/*