tests: Fix waitForPromise() in enter.js

This commit is contained in:
Richard Hansen 2021-02-07 02:11:28 -05:00 committed by John McLear
parent c625c611d2
commit 0ff8274d2e

View file

@ -39,21 +39,22 @@ describe('enter keystroke', function () {
while (i < numberOfLines) { while (i < numberOfLines) {
$lastLine = helper.padInner$('div').last(); $lastLine = helper.padInner$('div').last();
$lastLine.sendkeys('{enter}'); $lastLine.sendkeys('{enter}');
await helper.waitFor(() => helper.padInner$('div').length > previousLineLength); await helper.waitForPromise(() => helper.padInner$('div').length > previousLineLength);
previousLineLength = helper.padInner$('div').length; previousLineLength = helper.padInner$('div').length;
// check we can see the caret.. // check we can see the caret..
i++; i++;
} }
await helper.waitFor(() => helper.padInner$('div').length === numberOfLines + originalLength); await helper.waitForPromise(
() => helper.padInner$('div').length === numberOfLines + originalLength);
// is edited line fully visible? // is edited line fully visible?
const lastLine = helper.padInner$('div').last(); const lastLine = helper.padInner$('div').last();
const bottomOfLastLine = lastLine.offset().top + lastLine.height(); const bottomOfLastLine = lastLine.offset().top + lastLine.height();
const scrolledWindow = helper.padChrome$('iframe')[0]; const scrolledWindow = helper.padChrome$('iframe')[0];
await helper.waitFor(() => { await helper.waitForPromise(() => {
const scrolledAmount = scrolledWindow.contentWindow.pageYOffset + const scrolledAmount =
scrolledWindow.contentWindow.innerHeight; scrolledWindow.contentWindow.pageYOffset + scrolledWindow.contentWindow.innerHeight;
return scrolledAmount >= bottomOfLastLine; return scrolledAmount >= bottomOfLastLine;
}); });
}); });