mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-26 02:16:16 -04:00
Low hanging lint frontend tests (#4695)
* lint: low hanging specs/alphabet.js * lint: low hanging specs/authorship_of_editions.js * lint: low hanging specs/bold.js * lint: low hanging specs/caret.js * lint: low hanging specs/change_user_color.js * lint: low hanging specs/change_user_name.js * lint: low hanging specs/chat.js * lint: low hanging specs/chat_load_messages.js * lint: low hanging specs/clear_authorship_colors.js * lint: low hanging specs/delete.js * lint: low hanging specs/drag_and_drop.js * lint: low hanging specs/embed_value.js * lint: low hanging specs/enter.js * lint: low hanging specs/font_type.js * lint: low hanging specs/helper.js * lint: low hanging specs/importexport.js * lint: low hanging specs/importindents.js * lint: low hanging specs/indentation.js * lint: low hanging specs/italic.js * lint: low hanging specs/language.js * lint: low hanging specs/multiple_authors_clear_authorship_colors.js * lint: low hanging specs/ordered_list.js * lint: low hanging specs/pad_modal.js * lint: low hanging specs/redo.js * lint: low hanging specs/responsiveness.js * lint: low hanging specs/select_formatting_buttons.js * lint: low hanging specs/strikethrough.js * lint: low hanging specs/timeslider.js * lint: low hanging specs/timeslider_labels.js * lint: low hanging specs/timeslider_numeric_padID.js * lint: low hanging specs/timeslider_revisions.js * lint: low hanging specs/undo.js * lint: low hanging specs/unordered_list.js * lint: low hanging specs/xxauto_reconnect.js * lint: attempt to do remote_runner.js * lint: helper linting * lint: rate limit linting * use constructor for Event to make eslint happier * for squash: lint fix refinements * for squash: lint fix refinements Co-authored-by: Richard Hansen <rhansen@rhansen.org>
This commit is contained in:
parent
759e2aaec3
commit
915849b319
39 changed files with 595 additions and 357 deletions
|
@ -1,3 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
describe('author of pad edition', function () {
|
||||
const REGULAR_LINE = 0;
|
||||
const LINE_WITH_ORDERED_LIST = 1;
|
||||
|
@ -5,10 +7,11 @@ describe('author of pad edition', function () {
|
|||
|
||||
// author 1 creates a new pad with some content (regular lines and lists)
|
||||
before(function (done) {
|
||||
var padId = helper.newPad(() => {
|
||||
const padId = helper.newPad(() => {
|
||||
// make sure pad has at least 3 lines
|
||||
const $firstLine = helper.padInner$('div').first();
|
||||
const threeLines = ['regular line', 'line with ordered list', 'line with unordered list'].join('<br>');
|
||||
const threeLines = ['regular line', 'line with ordered list', 'line with unordered list']
|
||||
.join('<br>');
|
||||
$firstLine.html(threeLines);
|
||||
|
||||
// wait for lines to be processed by Etherpad
|
||||
|
@ -43,7 +46,8 @@ describe('author of pad edition', function () {
|
|||
setTimeout(() => {
|
||||
// Expire cookie, so author is changed after reloading the pad.
|
||||
// See https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#Example_4_Reset_the_previous_cookie
|
||||
helper.padChrome$.document.cookie = 'token=foo;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
|
||||
helper.padChrome$.document.cookie =
|
||||
'token=foo;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/';
|
||||
|
||||
helper.newPad(done, padId);
|
||||
}, 1000);
|
||||
|
@ -59,24 +63,22 @@ describe('author of pad edition', function () {
|
|||
changeLineAndCheckOnlyThatChangeIsFromThisAuthor(REGULAR_LINE, 'x', done);
|
||||
});
|
||||
|
||||
it('marks only the new content as changes of the second user on a line with ordered list', function (done) {
|
||||
it('marks only the new content as changes of the second user on a ' +
|
||||
'line with ordered list', function (done) {
|
||||
changeLineAndCheckOnlyThatChangeIsFromThisAuthor(LINE_WITH_ORDERED_LIST, 'y', done);
|
||||
});
|
||||
|
||||
it('marks only the new content as changes of the second user on a line with unordered list', function (done) {
|
||||
it('marks only the new content as changes of the second user on ' +
|
||||
'a line with unordered list', function (done) {
|
||||
changeLineAndCheckOnlyThatChangeIsFromThisAuthor(LINE_WITH_UNORDERED_LIST, 'z', done);
|
||||
});
|
||||
|
||||
/* ********************** Helper functions ************************ */
|
||||
var getLine = function (lineNumber) {
|
||||
return helper.padInner$('div').eq(lineNumber);
|
||||
};
|
||||
const getLine = (lineNumber) => helper.padInner$('div').eq(lineNumber);
|
||||
|
||||
const getAuthorFromClassList = function (classes) {
|
||||
return classes.find((cls) => cls.startsWith('author'));
|
||||
};
|
||||
const getAuthorFromClassList = (classes) => classes.find((cls) => cls.startsWith('author'));
|
||||
|
||||
var changeLineAndCheckOnlyThatChangeIsFromThisAuthor = function (lineNumber, textChange, done) {
|
||||
const changeLineAndCheckOnlyThatChangeIsFromThisAuthor = (lineNumber, textChange, done) => {
|
||||
// get original author class
|
||||
const classes = getLine(lineNumber).find('span').first().attr('class').split(' ');
|
||||
const originalAuthor = getAuthorFromClassList(classes);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue