lint: Fix bugs and style issues introduced in PR #4718

This fixes issues introduced in commit
f8a19c4527.
This commit is contained in:
Richard Hansen 2021-02-07 01:57:37 -05:00 committed by John McLear
parent 0ff8274d2e
commit 294f2a251f
6 changed files with 165 additions and 179 deletions

View file

@ -27,9 +27,7 @@ describe('drag and drop', function () {
const originalHTML = helper.padInner$('body').html(); const originalHTML = helper.padInner$('body').html();
const $undoButton = helper.padChrome$('.buttonicon-undo'); const $undoButton = helper.padChrome$('.buttonicon-undo');
$undoButton.click(); $undoButton.click();
await helper.waitForPromise( await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
() => originalHTML !== helper.padInner$('body').html()
);
}); });
it('moves text back to its original place', function (done) { it('moves text back to its original place', function (done) {
@ -66,9 +64,7 @@ describe('drag and drop', function () {
const originalHTML = helper.padInner$('body').html(); const originalHTML = helper.padInner$('body').html();
const $undoButton = helper.padChrome$('.buttonicon-undo'); const $undoButton = helper.padChrome$('.buttonicon-undo');
$undoButton.click(); $undoButton.click();
await helper.waitForPromise( await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
() => originalHTML !== helper.padInner$('body').html()
);
}); });
it('moves text back to its original place', function (done) { it('moves text back to its original place', function (done) {

View file

@ -1,6 +1,7 @@
'use strict'; 'use strict';
describe('assign ordered list', function () { describe('ordered_list.js', function () {
describe('assign ordered list', function () {
// create a new pad before each test run // create a new pad before each test run
beforeEach(function (cb) { beforeEach(function (cb) {
helper.newPad(cb); helper.newPad(cb);
@ -23,12 +24,12 @@ describe('assign ordered list', function () {
const originalHTML = helper.padInner$('body').html(); const originalHTML = helper.padInner$('body').html();
makeSureShortcutIsEnabled('cmdShiftN'); makeSureShortcutIsEnabled('cmdShiftN');
triggerCtrlShiftShortcut('N'); triggerCtrlShiftShortcut('N');
await helper.waitForPromise( await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
() => helper.padInner$('body').html !== originalHTML);
}); });
it('inserts unordered list', function (done) { it('inserts unordered list', function (done) {
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1).done(done); helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
.done(done);
}); });
}); });
@ -37,15 +38,15 @@ describe('assign ordered list', function () {
const originalHTML = helper.padInner$('body').html(); const originalHTML = helper.padInner$('body').html();
makeSureShortcutIsDisabled('cmdShiftN'); makeSureShortcutIsDisabled('cmdShiftN');
triggerCtrlShiftShortcut('N'); triggerCtrlShiftShortcut('N');
await helper.waitForPromise( await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
() => helper.padInner$('body').html !== originalHTML);
}); });
it('does not insert unordered list', function (done) { it('does not insert unordered list', function (done) {
helper.waitFor( helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
() => helper.padInner$('div').first().find('ol li').length === 1).done(() => { .done(() => {
expect().fail(() => 'Unordered list inserted, should ignore shortcut'); expect().fail(() => 'Unordered list inserted, should ignore shortcut');
}).fail(() => { })
.fail(() => {
done(); done();
}); });
}); });
@ -58,12 +59,12 @@ describe('assign ordered list', function () {
const originalHTML = helper.padInner$('body').html(); const originalHTML = helper.padInner$('body').html();
makeSureShortcutIsEnabled('cmdShift1'); makeSureShortcutIsEnabled('cmdShift1');
triggerCtrlShiftShortcut('1'); triggerCtrlShiftShortcut('1');
await helper.waitForPromise( await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
() => helper.padInner$('body').html !== originalHTML);
}); });
it('inserts unordered list', function (done) { it('inserts unordered list', function (done) {
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1).done(done); helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
.done(done);
}); });
}); });
@ -72,15 +73,15 @@ describe('assign ordered list', function () {
const originalHTML = helper.padInner$('body').html(); const originalHTML = helper.padInner$('body').html();
makeSureShortcutIsDisabled('cmdShift1'); makeSureShortcutIsDisabled('cmdShift1');
triggerCtrlShiftShortcut('1'); triggerCtrlShiftShortcut('1');
await helper.waitForPromise( await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
() => helper.padInner$('body').html !== originalHTML);
}); });
it('does not insert unordered list', function (done) { it('does not insert unordered list', function (done) {
helper.waitFor( helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
() => helper.padInner$('div').first().find('ol li').length === 1).done(() => { .done(() => {
expect().fail(() => 'Unordered list inserted, should ignore shortcut'); expect().fail(() => 'Unordered list inserted, should ignore shortcut');
}).fail(() => { })
.fail(() => {
done(); done();
}); });
}); });
@ -129,6 +130,7 @@ describe('assign ordered list', function () {
const makeSureShortcutIsEnabled = (shortcut) => { const makeSureShortcutIsEnabled = (shortcut) => {
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = true; helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = true;
}; };
});
describe('Pressing Tab in an OL increases and decreases indentation', function () { describe('Pressing Tab in an OL increases and decreases indentation', function () {
// create a new pad before each test run // create a new pad before each test run

View file

@ -28,7 +28,7 @@ describe('Pad modal', function () {
clickOnPadInner(); clickOnPadInner();
const $modal = helper.padChrome$(MODAL_SELECTOR); const $modal = helper.padChrome$(MODAL_SELECTOR);
const modalIsVisible = $modal.hasClass('popup-show'); const modalIsVisible = $modal.hasClass('popup-show');
helper.waitForPromise(() => $modal.hasClass('popup-show') === true);
expect(modalIsVisible).to.be(true); expect(modalIsVisible).to.be(true);
done(); done();
@ -37,12 +37,10 @@ describe('Pad modal', function () {
context('and user clicks on pad outer', function () { context('and user clicks on pad outer', function () {
it('does not close the modal', function (done) { it('does not close the modal', function (done) {
clickOnPadOuter();
const $modal = helper.padChrome$(MODAL_SELECTOR); const $modal = helper.padChrome$(MODAL_SELECTOR);
const modalIsVisible = $modal.hasClass('popup-show'); const modalIsVisible = $modal.hasClass('popup-show');
clickOnPadOuter();
helper.waitForPromise(() => $modal.hasClass('popup-show') === true);
expect(modalIsVisible).to.be(true); expect(modalIsVisible).to.be(true);
done(); done();
@ -69,20 +67,16 @@ describe('Pad modal', function () {
}); });
*/ */
context('and user clicks on editor', function () { context('and user clicks on editor', function () {
it('closes the modal', function (done) { it('closes the modal', async function () {
clickOnPadInner(); clickOnPadInner();
helper.waitForPromise(() => isModalOpened(MODAL_SELECTOR) === false); await helper.waitForPromise(() => isModalOpened(MODAL_SELECTOR) === false);
expect(isModalOpened(MODAL_SELECTOR)).to.be(false);
done();
}); });
}); });
context('and user clicks on pad outer', function () { context('and user clicks on pad outer', function () {
it('closes the modal', function (done) { it('closes the modal', async function () {
clickOnPadOuter(); clickOnPadOuter();
helper.waitForPromise(() => isModalOpened(MODAL_SELECTOR) === false); await helper.waitForPromise(() => isModalOpened(MODAL_SELECTOR) === false);
expect(isModalOpened(MODAL_SELECTOR)).to.be(false);
done();
}); });
}); });
}); });

View file

@ -1,14 +1,12 @@
'use strict'; 'use strict';
describe('scrolls to line', function () { describe('scrollTo.js', function () {
describe('scrolls to line', function () {
// create a new pad with URL hash set before each test run // create a new pad with URL hash set before each test run
before(async function () { before(async function () {
this.timeout(60000); this.timeout(60000);
await new Promise((resolve, reject) => helper.newPad({ await new Promise((resolve, reject) => helper.newPad({
cb: (err) => { cb: (err) => (err != null) ? reject(err) : resolve(),
if (err != null) return reject(err);
resolve();
},
hash: 'L4', hash: 'L4',
})); }));
}); });
@ -22,16 +20,14 @@ describe('scrolls to line', function () {
return (topOffset >= 100); return (topOffset >= 100);
}); });
}); });
});
describe('doesnt break on weird hash input', function () { describe('doesnt break on weird hash input', function () {
// create a new pad with URL hash set before each test run // create a new pad with URL hash set before each test run
before(async function () { before(async function () {
this.timeout(60000); this.timeout(60000);
await new Promise((resolve, reject) => helper.newPad({ await new Promise((resolve, reject) => helper.newPad({
cb: (err) => { cb: (err) => (err != null) ? reject(err) : resolve(),
if (err != null) return reject(err);
resolve();
},
hash: '#DEEZ123123NUTS', hash: '#DEEZ123123NUTS',
})); }));
}); });

View file

@ -39,7 +39,7 @@ describe('select formatting buttons when selection has style applied', function
const originalHTML = helper.padInner$('body').html(); const originalHTML = helper.padInner$('body').html();
const $undoButton = helper.padChrome$('.buttonicon-undo'); const $undoButton = helper.padChrome$('.buttonicon-undo');
$undoButton.click(); $undoButton.click();
await helper.waitFor(() => originalHTML !== helper.padInner$('body').html()); await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
}; };
const testIfFormattingButtonIsDeselected = function (style) { const testIfFormattingButtonIsDeselected = function (style) {
@ -86,7 +86,6 @@ describe('select formatting buttons when selection has style applied', function
const inner$ = helper.padInner$; const inner$ = helper.padInner$;
const originalHTML = helper.padInner$('body').html(); const originalHTML = helper.padInner$('body').html();
helper.waitFor(() => originalHTML !== helper.padInner$('body').html());
// get the first text element out of the inner iframe // get the first text element out of the inner iframe
const $firstTextElement = inner$('div').first(); const $firstTextElement = inner$('div').first();
@ -97,8 +96,7 @@ describe('select formatting buttons when selection has style applied', function
e.ctrlKey = true; // Control key e.ctrlKey = true; // Control key
e.which = key.charCodeAt(0); // I, U, B, 5 e.which = key.charCodeAt(0); // I, U, B, 5
inner$('#innerdocbody').trigger(e); inner$('#innerdocbody').trigger(e);
await helper.waitForPromise( await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
() => originalHTML !== helper.padInner$('body').html());
}; };
STYLES.forEach((style) => { STYLES.forEach((style) => {
@ -130,12 +128,10 @@ describe('select formatting buttons when selection has style applied', function
}); });
context('when user applies a style and the selection does not change', function () { context('when user applies a style and the selection does not change', function () {
const style = STYLES[0]; // italic
it('selects the style button', async function () { it('selects the style button', async function () {
const style = STYLES[0]; // italic
applyStyleOnLine(style, FIRST_LINE); applyStyleOnLine(style, FIRST_LINE);
await helper.waitForPromise(() => isButtonSelected(style) === true); await helper.waitForPromise(() => isButtonSelected(style) === true);
expect(isButtonSelected(style)).to.be(true);
applyStyleOnLine(style, FIRST_LINE); applyStyleOnLine(style, FIRST_LINE);
}); });
}); });

View file

@ -1,6 +1,7 @@
'use strict'; 'use strict';
describe('assign unordered list', function () { describe('unordered_list.js', function () {
describe('assign unordered list', function () {
// create a new pad before each test run // create a new pad before each test run
beforeEach(function (cb) { beforeEach(function (cb) {
helper.newPad(cb); helper.newPad(cb);
@ -31,6 +32,7 @@ describe('assign unordered list', function () {
}); });
}); });
}); });
});
describe('unassign unordered list', function () { describe('unassign unordered list', function () {
// create a new pad before each test run // create a new pad before each test run