tests: Refine frontend tests

* Switch from `helper.newPad()` to `helper.aNewPad()`.
  * Promisify.
  * Delete redundant logic.
  * Lint fixes.
This commit is contained in:
Richard Hansen 2021-03-31 21:14:02 -04:00 committed by webzwo0i
parent 3790c0e41c
commit bbf89dfcf9
35 changed files with 697 additions and 842 deletions

View file

@ -2,11 +2,12 @@
describe('enter keystroke', function () {
// create a new pad before each test run
beforeEach(function (cb) {
helper.newPad(cb);
beforeEach(async function () {
this.timeout(60000);
await helper.aNewPad();
});
it('creates a new line & puts cursor onto a new line', function (done) {
it('creates a new line & puts cursor onto a new line', async function () {
this.timeout(2000);
const inner$ = helper.padInner$;
@ -19,14 +20,13 @@ describe('enter keystroke', function () {
// simulate key presses to enter content
$firstTextElement.sendkeys('{enter}');
helper.waitFor(() => inner$('div').first().text() === '').done(() => {
const $newSecondLine = inner$('div').first().next();
const newFirstTextElementValue = inner$('div').first().text();
expect(newFirstTextElementValue).to.be(''); // expect the first line to be blank
// expect the second line to be the same as the original first line.
expect($newSecondLine.text()).to.be(originalTextValue);
done();
});
await helper.waitForPromise(() => inner$('div').first().text() === '');
const $newSecondLine = inner$('div').first().next();
const newFirstTextElementValue = inner$('div').first().text();
expect(newFirstTextElementValue).to.be(''); // expect the first line to be blank
// expect the second line to be the same as the original first line.
expect($newSecondLine.text()).to.be(originalTextValue);
});
it('enter is always visible after event', async function () {