tests: New helper.clearPad method

This commit is contained in:
Richard Hansen 2020-12-13 18:39:09 -05:00 committed by John McLear
parent ca01856f94
commit 1c388ca66e
2 changed files with 18 additions and 12 deletions

View file

@ -219,3 +219,20 @@ helper.timesliderTextLines = function () {
return $(this).text();
}).get();
};
helper.padIsEmpty = () => (
!helper.padInner$.document.getSelection().isCollapsed ||
(helper.padInner$('div').length === 1 && helper.padInner$('div').first().html() === '<br>'));
helper.clearPad = async () => {
if (helper.padIsEmpty()) return;
const commitsBefore = helper.commits.length;
const lines = helper.linesDiv();
helper.selectLines(lines[0], lines[lines.length - 1]);
await helper.waitForPromise(() => !helper.padInner$.document.getSelection().isCollapsed);
const e = new helper.padInner$.Event(helper.evtType);
e.keyCode = 8; // delete key
helper.padInner$('#innerdocbody').trigger(e);
await helper.waitForPromise(helper.padIsEmpty);
await helper.waitForPromise(() => helper.commits.length > commitsBefore);
};