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 $undoButton = helper.padChrome$('.buttonicon-undo');
$undoButton.click();
await helper.waitForPromise(
() => originalHTML !== helper.padInner$('body').html()
);
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
});
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 $undoButton = helper.padChrome$('.buttonicon-undo');
$undoButton.click();
await helper.waitForPromise(
() => originalHTML !== helper.padInner$('body').html()
);
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
});
it('moves text back to its original place', function (done) {

View file

@ -1,135 +1,137 @@
'use strict';
describe('assign ordered list', function () {
// create a new pad before each test run
beforeEach(function (cb) {
helper.newPad(cb);
this.timeout(60000);
});
it('inserts ordered list text', function (done) {
const inner$ = helper.padInner$;
const chrome$ = helper.padChrome$;
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
$insertorderedlistButton.click();
helper.waitFor(() => inner$('div').first().find('ol li').length === 1).done(done);
});
context('when user presses Ctrl+Shift+N', function () {
context('and pad shortcut is enabled', function () {
beforeEach(async function () {
const originalHTML = helper.padInner$('body').html();
makeSureShortcutIsEnabled('cmdShiftN');
triggerCtrlShiftShortcut('N');
await helper.waitForPromise(
() => helper.padInner$('body').html !== originalHTML);
});
it('inserts unordered list', function (done) {
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1).done(done);
});
describe('ordered_list.js', function () {
describe('assign ordered list', function () {
// create a new pad before each test run
beforeEach(function (cb) {
helper.newPad(cb);
this.timeout(60000);
});
context('and pad shortcut is disabled', function () {
beforeEach(async function () {
const originalHTML = helper.padInner$('body').html();
makeSureShortcutIsDisabled('cmdShiftN');
triggerCtrlShiftShortcut('N');
await helper.waitForPromise(
() => helper.padInner$('body').html !== originalHTML);
it('inserts ordered list text', function (done) {
const inner$ = helper.padInner$;
const chrome$ = helper.padChrome$;
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
$insertorderedlistButton.click();
helper.waitFor(() => inner$('div').first().find('ol li').length === 1).done(done);
});
context('when user presses Ctrl+Shift+N', function () {
context('and pad shortcut is enabled', function () {
beforeEach(async function () {
const originalHTML = helper.padInner$('body').html();
makeSureShortcutIsEnabled('cmdShiftN');
triggerCtrlShiftShortcut('N');
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
});
it('inserts unordered list', function (done) {
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
.done(done);
});
});
it('does not insert unordered list', function (done) {
helper.waitFor(
() => helper.padInner$('div').first().find('ol li').length === 1).done(() => {
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
}).fail(() => {
done();
context('and pad shortcut is disabled', function () {
beforeEach(async function () {
const originalHTML = helper.padInner$('body').html();
makeSureShortcutIsDisabled('cmdShiftN');
triggerCtrlShiftShortcut('N');
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
});
it('does not insert unordered list', function (done) {
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
.done(() => {
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
})
.fail(() => {
done();
});
});
});
});
});
context('when user presses Ctrl+Shift+1', function () {
context('and pad shortcut is enabled', function () {
beforeEach(async function () {
const originalHTML = helper.padInner$('body').html();
makeSureShortcutIsEnabled('cmdShift1');
triggerCtrlShiftShortcut('1');
await helper.waitForPromise(
() => helper.padInner$('body').html !== originalHTML);
context('when user presses Ctrl+Shift+1', function () {
context('and pad shortcut is enabled', function () {
beforeEach(async function () {
const originalHTML = helper.padInner$('body').html();
makeSureShortcutIsEnabled('cmdShift1');
triggerCtrlShiftShortcut('1');
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
});
it('inserts unordered list', function (done) {
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
.done(done);
});
});
it('inserts unordered list', function (done) {
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1).done(done);
});
});
context('and pad shortcut is disabled', function () {
beforeEach(async function () {
const originalHTML = helper.padInner$('body').html();
makeSureShortcutIsDisabled('cmdShift1');
triggerCtrlShiftShortcut('1');
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
});
context('and pad shortcut is disabled', function () {
beforeEach(async function () {
const originalHTML = helper.padInner$('body').html();
makeSureShortcutIsDisabled('cmdShift1');
triggerCtrlShiftShortcut('1');
await helper.waitForPromise(
() => helper.padInner$('body').html !== originalHTML);
});
it('does not insert unordered list', function (done) {
helper.waitFor(
() => helper.padInner$('div').first().find('ol li').length === 1).done(() => {
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
}).fail(() => {
done();
it('does not insert unordered list', function (done) {
helper.waitFor(() => helper.padInner$('div').first().find('ol li').length === 1)
.done(() => {
expect().fail(() => 'Unordered list inserted, should ignore shortcut');
})
.fail(() => {
done();
});
});
});
});
});
xit('issue #1125 keeps the numbered list on enter for the new line', function (done) {
// EMULATES PASTING INTO A PAD
const inner$ = helper.padInner$;
const chrome$ = helper.padChrome$;
xit('issue #1125 keeps the numbered list on enter for the new line', function (done) {
// EMULATES PASTING INTO A PAD
const inner$ = helper.padInner$;
const chrome$ = helper.padChrome$;
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
$insertorderedlistButton.click();
const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist');
$insertorderedlistButton.click();
// type a bit, make a line break and type again
const $firstTextElement = inner$('div span').first();
$firstTextElement.sendkeys('line 1');
$firstTextElement.sendkeys('{enter}');
$firstTextElement.sendkeys('line 2');
$firstTextElement.sendkeys('{enter}');
// type a bit, make a line break and type again
const $firstTextElement = inner$('div span').first();
$firstTextElement.sendkeys('line 1');
$firstTextElement.sendkeys('{enter}');
$firstTextElement.sendkeys('line 2');
$firstTextElement.sendkeys('{enter}');
helper.waitFor(() => inner$('div span').first().text().indexOf('line 2') === -1).done(() => {
const $newSecondLine = inner$('div').first().next();
const hasOLElement = $newSecondLine.find('ol li').length === 1;
expect(hasOLElement).to.be(true);
expect($newSecondLine.text()).to.be('line 2');
const hasLineNumber = $newSecondLine.find('ol').attr('start') === 2;
// This doesn't work because pasting in content doesn't work
expect(hasLineNumber).to.be(true);
done();
helper.waitFor(() => inner$('div span').first().text().indexOf('line 2') === -1).done(() => {
const $newSecondLine = inner$('div').first().next();
const hasOLElement = $newSecondLine.find('ol li').length === 1;
expect(hasOLElement).to.be(true);
expect($newSecondLine.text()).to.be('line 2');
const hasLineNumber = $newSecondLine.find('ol').attr('start') === 2;
// This doesn't work because pasting in content doesn't work
expect(hasLineNumber).to.be(true);
done();
});
});
const triggerCtrlShiftShortcut = (shortcutChar) => {
const inner$ = helper.padInner$;
const e = new inner$.Event(helper.evtType);
e.ctrlKey = true;
e.shiftKey = true;
e.which = shortcutChar.toString().charCodeAt(0);
inner$('#innerdocbody').trigger(e);
};
const makeSureShortcutIsDisabled = (shortcut) => {
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = false;
};
const makeSureShortcutIsEnabled = (shortcut) => {
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = true;
};
});
const triggerCtrlShiftShortcut = (shortcutChar) => {
const inner$ = helper.padInner$;
const e = new inner$.Event(helper.evtType);
e.ctrlKey = true;
e.shiftKey = true;
e.which = shortcutChar.toString().charCodeAt(0);
inner$('#innerdocbody').trigger(e);
};
const makeSureShortcutIsDisabled = (shortcut) => {
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = false;
};
const makeSureShortcutIsEnabled = (shortcut) => {
helper.padChrome$.window.clientVars.padShortcutEnabled[shortcut] = true;
};
describe('Pressing Tab in an OL increases and decreases indentation', function () {
// create a new pad before each test run
beforeEach(function (cb) {

View file

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

View file

@ -1,25 +1,24 @@
'use strict';
describe('scrolls to line', function () {
// create a new pad with URL hash set before each test run
before(async function () {
this.timeout(60000);
await new Promise((resolve, reject) => helper.newPad({
cb: (err) => {
if (err != null) return reject(err);
resolve();
},
hash: 'L4',
}));
});
describe('scrollTo.js', function () {
describe('scrolls to line', function () {
// create a new pad with URL hash set before each test run
before(async function () {
this.timeout(60000);
await new Promise((resolve, reject) => helper.newPad({
cb: (err) => (err != null) ? reject(err) : resolve(),
hash: 'L4',
}));
});
it('Scrolls down to Line 4', async function () {
this.timeout(10000);
const chrome$ = helper.padChrome$;
await helper.waitForPromise(() => {
const topOffset = parseInt(chrome$('iframe').first('iframe')
.contents().find('#outerdocbody').css('top'));
return (topOffset >= 100);
it('Scrolls down to Line 4', async function () {
this.timeout(10000);
const chrome$ = helper.padChrome$;
await helper.waitForPromise(() => {
const topOffset = parseInt(chrome$('iframe').first('iframe')
.contents().find('#outerdocbody').css('top'));
return (topOffset >= 100);
});
});
});
@ -28,10 +27,7 @@ describe('scrolls to line', function () {
before(async function () {
this.timeout(60000);
await new Promise((resolve, reject) => helper.newPad({
cb: (err) => {
if (err != null) return reject(err);
resolve();
},
cb: (err) => (err != null) ? reject(err) : resolve(),
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 $undoButton = helper.padChrome$('.buttonicon-undo');
$undoButton.click();
await helper.waitFor(() => originalHTML !== helper.padInner$('body').html());
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
};
const testIfFormattingButtonIsDeselected = function (style) {
@ -86,7 +86,6 @@ describe('select formatting buttons when selection has style applied', function
const inner$ = helper.padInner$;
const originalHTML = helper.padInner$('body').html();
helper.waitFor(() => originalHTML !== helper.padInner$('body').html());
// get the first text element out of the inner iframe
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.which = key.charCodeAt(0); // I, U, B, 5
inner$('#innerdocbody').trigger(e);
await helper.waitForPromise(
() => originalHTML !== helper.padInner$('body').html());
await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML);
};
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 () {
const style = STYLES[0]; // italic
it('selects the style button', async function () {
const style = STYLES[0]; // italic
applyStyleOnLine(style, FIRST_LINE);
await helper.waitForPromise(() => isButtonSelected(style) === true);
expect(isButtonSelected(style)).to.be(true);
applyStyleOnLine(style, FIRST_LINE);
});
});

View file

@ -1,33 +1,35 @@
'use strict';
describe('assign unordered list', function () {
// create a new pad before each test run
beforeEach(function (cb) {
helper.newPad(cb);
this.timeout(60000);
});
describe('unordered_list.js', function () {
describe('assign unordered list', function () {
// create a new pad before each test run
beforeEach(function (cb) {
helper.newPad(cb);
this.timeout(60000);
});
it('insert unordered list text then removes by outdent', function (done) {
const inner$ = helper.padInner$;
const chrome$ = helper.padChrome$;
const originalText = inner$('div').first().text();
it('insert unordered list text then removes by outdent', function (done) {
const inner$ = helper.padInner$;
const chrome$ = helper.padChrome$;
const originalText = inner$('div').first().text();
const $insertunorderedlistButton = chrome$('.buttonicon-insertunorderedlist');
$insertunorderedlistButton.click();
const $insertunorderedlistButton = chrome$('.buttonicon-insertunorderedlist');
$insertunorderedlistButton.click();
helper.waitFor(() => {
const newText = inner$('div').first().text();
if (newText === originalText) {
return inner$('div').first().find('ul li').length === 1;
}
}).done(() => {
// remove indentation by bullet and ensure text string remains the same
chrome$('.buttonicon-outdent').click();
helper.waitFor(() => {
const newText = inner$('div').first().text();
return (newText === originalText);
if (newText === originalText) {
return inner$('div').first().find('ul li').length === 1;
}
}).done(() => {
done();
// remove indentation by bullet and ensure text string remains the same
chrome$('.buttonicon-outdent').click();
helper.waitFor(() => {
const newText = inner$('div').first().text();
return (newText === originalText);
}).done(() => {
done();
});
});
});
});