mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 16:06:16 -04:00
lint: Run eslint --fix
on bin/
and tests/
This commit is contained in:
parent
0625739cb8
commit
b8d07a42eb
78 changed files with 4319 additions and 4599 deletions
|
@ -1,105 +1,101 @@
|
|||
describe("select formatting buttons when selection has style applied", function(){
|
||||
var STYLES = ['italic', 'bold', 'underline', 'strikethrough'];
|
||||
var SHORTCUT_KEYS = ['I', 'B', 'U', '5']; // italic, bold, underline, strikethrough
|
||||
var FIRST_LINE = 0;
|
||||
describe('select formatting buttons when selection has style applied', function () {
|
||||
const STYLES = ['italic', 'bold', 'underline', 'strikethrough'];
|
||||
const SHORTCUT_KEYS = ['I', 'B', 'U', '5']; // italic, bold, underline, strikethrough
|
||||
const FIRST_LINE = 0;
|
||||
|
||||
before(function(cb){
|
||||
before(function (cb) {
|
||||
helper.newPad(cb);
|
||||
this.timeout(60000);
|
||||
});
|
||||
|
||||
var applyStyleOnLine = function(style, line) {
|
||||
var chrome$ = helper.padChrome$;
|
||||
const applyStyleOnLine = function (style, line) {
|
||||
const chrome$ = helper.padChrome$;
|
||||
selectLine(line);
|
||||
var $formattingButton = chrome$('.buttonicon-' + style);
|
||||
const $formattingButton = chrome$(`.buttonicon-${style}`);
|
||||
$formattingButton.click();
|
||||
}
|
||||
};
|
||||
|
||||
var isButtonSelected = function(style) {
|
||||
var chrome$ = helper.padChrome$;
|
||||
var $formattingButton = chrome$('.buttonicon-' + style);
|
||||
return $formattingButton.parent().hasClass('selected');
|
||||
}
|
||||
const isButtonSelected = function (style) {
|
||||
const chrome$ = helper.padChrome$;
|
||||
const $formattingButton = chrome$(`.buttonicon-${style}`);
|
||||
return $formattingButton.parent().hasClass('selected');
|
||||
};
|
||||
|
||||
var selectLine = function(lineNumber, offsetStart, offsetEnd) {
|
||||
var inner$ = helper.padInner$;
|
||||
var $line = inner$("div").eq(lineNumber);
|
||||
var selectLine = function (lineNumber, offsetStart, offsetEnd) {
|
||||
const inner$ = helper.padInner$;
|
||||
const $line = inner$('div').eq(lineNumber);
|
||||
helper.selectLines($line, $line, offsetStart, offsetEnd);
|
||||
}
|
||||
};
|
||||
|
||||
var placeCaretOnLine = function(lineNumber) {
|
||||
var inner$ = helper.padInner$;
|
||||
var $line = inner$("div").eq(lineNumber);
|
||||
const placeCaretOnLine = function (lineNumber) {
|
||||
const inner$ = helper.padInner$;
|
||||
const $line = inner$('div').eq(lineNumber);
|
||||
$line.sendkeys('{leftarrow}');
|
||||
}
|
||||
};
|
||||
|
||||
var undo = function() {
|
||||
var $undoButton = helper.padChrome$(".buttonicon-undo");
|
||||
const undo = function () {
|
||||
const $undoButton = helper.padChrome$('.buttonicon-undo');
|
||||
$undoButton.click();
|
||||
}
|
||||
};
|
||||
|
||||
var testIfFormattingButtonIsDeselected = function(style) {
|
||||
it('deselects the ' + style + ' button', function(done) {
|
||||
helper.waitFor(function(){
|
||||
return isButtonSelected(style) === false;
|
||||
}).done(done)
|
||||
const testIfFormattingButtonIsDeselected = function (style) {
|
||||
it(`deselects the ${style} button`, function (done) {
|
||||
helper.waitFor(() => isButtonSelected(style) === false).done(done);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var testIfFormattingButtonIsSelected = function(style) {
|
||||
it('selects the ' + style + ' button', function(done) {
|
||||
helper.waitFor(function(){
|
||||
return isButtonSelected(style);
|
||||
}).done(done)
|
||||
const testIfFormattingButtonIsSelected = function (style) {
|
||||
it(`selects the ${style} button`, function (done) {
|
||||
helper.waitFor(() => isButtonSelected(style)).done(done);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var applyStyleOnLineAndSelectIt = function(line, style, cb) {
|
||||
const applyStyleOnLineAndSelectIt = function (line, style, cb) {
|
||||
applyStyleOnLineOnFullLineAndRemoveSelection(line, style, selectLine, cb);
|
||||
}
|
||||
};
|
||||
|
||||
var applyStyleOnLineAndPlaceCaretOnit = function(line, style, cb) {
|
||||
const applyStyleOnLineAndPlaceCaretOnit = function (line, style, cb) {
|
||||
applyStyleOnLineOnFullLineAndRemoveSelection(line, style, placeCaretOnLine, cb);
|
||||
}
|
||||
};
|
||||
|
||||
var applyStyleOnLineOnFullLineAndRemoveSelection = function(line, style, selectTarget, cb) {
|
||||
var applyStyleOnLineOnFullLineAndRemoveSelection = function (line, style, selectTarget, cb) {
|
||||
// see if line html has changed
|
||||
var inner$ = helper.padInner$;
|
||||
var oldLineHTML = inner$.find("div")[line];
|
||||
const inner$ = helper.padInner$;
|
||||
const oldLineHTML = inner$.find('div')[line];
|
||||
applyStyleOnLine(style, line);
|
||||
|
||||
helper.waitFor(function(){
|
||||
var lineHTML = inner$.find("div")[line];
|
||||
helper.waitFor(() => {
|
||||
const lineHTML = inner$.find('div')[line];
|
||||
return lineHTML !== oldLineHTML;
|
||||
});
|
||||
// remove selection from previous line
|
||||
// remove selection from previous line
|
||||
selectLine(line + 1);
|
||||
//setTimeout(function() {
|
||||
// select the text or place the caret on a position that
|
||||
// has the formatting text applied previously
|
||||
selectTarget(line);
|
||||
cb();
|
||||
//}, 1000);
|
||||
}
|
||||
// setTimeout(function() {
|
||||
// select the text or place the caret on a position that
|
||||
// has the formatting text applied previously
|
||||
selectTarget(line);
|
||||
cb();
|
||||
// }, 1000);
|
||||
};
|
||||
|
||||
var pressFormattingShortcutOnSelection = function(key) {
|
||||
var inner$ = helper.padInner$;
|
||||
var chrome$ = helper.padChrome$;
|
||||
const pressFormattingShortcutOnSelection = function (key) {
|
||||
const inner$ = helper.padInner$;
|
||||
const chrome$ = helper.padChrome$;
|
||||
|
||||
//get the first text element out of the inner iframe
|
||||
var $firstTextElement = inner$("div").first();
|
||||
// get the first text element out of the inner iframe
|
||||
const $firstTextElement = inner$('div').first();
|
||||
|
||||
//select this text element
|
||||
// select this text element
|
||||
$firstTextElement.sendkeys('{selectall}');
|
||||
|
||||
var e = inner$.Event(helper.evtType);
|
||||
const e = inner$.Event(helper.evtType);
|
||||
e.ctrlKey = true; // Control key
|
||||
e.which = key.charCodeAt(0); // I, U, B, 5
|
||||
inner$("#innerdocbody").trigger(e);
|
||||
}
|
||||
inner$('#innerdocbody').trigger(e);
|
||||
};
|
||||
|
||||
STYLES.forEach(function(style){
|
||||
context('when selection is in a text with ' + style + ' applied', function(){
|
||||
STYLES.forEach((style) => {
|
||||
context(`when selection is in a text with ${style} applied`, function () {
|
||||
before(function (done) {
|
||||
this.timeout(4000);
|
||||
applyStyleOnLineAndSelectIt(FIRST_LINE, style, done);
|
||||
|
@ -112,7 +108,7 @@ describe("select formatting buttons when selection has style applied", function(
|
|||
testIfFormattingButtonIsSelected(style);
|
||||
});
|
||||
|
||||
context('when caret is in a position with ' + style + ' applied', function(){
|
||||
context(`when caret is in a position with ${style} applied`, function () {
|
||||
before(function (done) {
|
||||
this.timeout(4000);
|
||||
applyStyleOnLineAndPlaceCaretOnit(FIRST_LINE, style, done);
|
||||
|
@ -122,12 +118,12 @@ describe("select formatting buttons when selection has style applied", function(
|
|||
undo();
|
||||
});
|
||||
|
||||
testIfFormattingButtonIsSelected(style)
|
||||
testIfFormattingButtonIsSelected(style);
|
||||
});
|
||||
});
|
||||
|
||||
context('when user applies a style and the selection does not change', function() {
|
||||
var style = STYLES[0]; // italic
|
||||
context('when user applies a style and the selection does not change', function () {
|
||||
const style = STYLES[0]; // italic
|
||||
before(function () {
|
||||
applyStyleOnLine(style, FIRST_LINE);
|
||||
});
|
||||
|
@ -143,16 +139,16 @@ describe("select formatting buttons when selection has style applied", function(
|
|||
});
|
||||
});
|
||||
|
||||
SHORTCUT_KEYS.forEach(function(key, index){
|
||||
var styleOfTheShortcut = STYLES[index]; // italic, bold, ...
|
||||
context('when user presses CMD + ' + key, function() {
|
||||
SHORTCUT_KEYS.forEach((key, index) => {
|
||||
const styleOfTheShortcut = STYLES[index]; // italic, bold, ...
|
||||
context(`when user presses CMD + ${key}`, function () {
|
||||
before(function () {
|
||||
pressFormattingShortcutOnSelection(key);
|
||||
});
|
||||
|
||||
testIfFormattingButtonIsSelected(styleOfTheShortcut);
|
||||
|
||||
context('and user presses CMD + ' + key + ' again', function() {
|
||||
context(`and user presses CMD + ${key} again`, function () {
|
||||
before(function () {
|
||||
pressFormattingShortcutOnSelection(key);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue