pad.pub0.org/tests/frontend/specs/unordered_list.js

163 lines
5.3 KiB
JavaScript
Raw Normal View History

describe('assign unordered list', function () {
// create a new pad before each test run
beforeEach(function (cb) {
2014-12-28 23:30:11 +00:00
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();
2014-12-28 23:30:11 +00:00
const $insertunorderedlistButton = chrome$('.buttonicon-insertunorderedlist');
2014-12-28 23:30:11 +00:00
$insertunorderedlistButton.click();
helper.waitFor(() => {
const newText = inner$('div').first().text();
if (newText === originalText) {
return inner$('div').first().find('ul li').length === 1;
2014-12-28 23:30:11 +00:00
}
}).done(() => {
2014-12-28 23:30:11 +00:00
// remove indentation by bullet and ensure text string remains the same
chrome$('.buttonicon-outdent').click();
helper.waitFor(() => {
const newText = inner$('div').first().text();
2014-12-28 23:30:11 +00:00
return (newText === originalText);
}).done(() => {
2014-12-28 23:30:11 +00:00
done();
});
});
});
});
2020-06-05 21:18:58 +00:00
describe('unassign unordered list', function () {
// create a new pad before each test run
beforeEach(function (cb) {
2020-06-05 21:18:58 +00:00
helper.newPad(cb);
this.timeout(60000);
});
it('insert unordered list text then remove by clicking list again', function (done) {
const inner$ = helper.padInner$;
const chrome$ = helper.padChrome$;
const originalText = inner$('div').first().text();
2020-06-05 21:18:58 +00:00
const $insertunorderedlistButton = chrome$('.buttonicon-insertunorderedlist');
2020-06-05 21:18:58 +00:00
$insertunorderedlistButton.click();
helper.waitFor(() => {
const newText = inner$('div').first().text();
if (newText === originalText) {
return inner$('div').first().find('ul li').length === 1;
2020-06-05 21:18:58 +00:00
}
}).done(() => {
2020-06-05 21:18:58 +00:00
// remove indentation by bullet and ensure text string remains the same
$insertunorderedlistButton.click();
helper.waitFor(() => {
const isList = inner$('div').find('ul').length === 1;
2020-06-05 21:18:58 +00:00
// sohuldn't be list
return (isList === false);
}).done(() => {
2020-06-05 21:18:58 +00:00
done();
});
});
});
});
describe('keep unordered list on enter key', function () {
// create a new pad before each test run
beforeEach(function (cb) {
2020-06-05 21:18:58 +00:00
helper.newPad(cb);
this.timeout(60000);
});
it('Keeps the unordered list on enter for the new line', function (done) {
const inner$ = helper.padInner$;
const chrome$ = helper.padChrome$;
2020-06-05 21:18:58 +00:00
const $insertorderedlistButton = chrome$('.buttonicon-insertunorderedlist');
2020-06-05 21:18:58 +00:00
$insertorderedlistButton.click();
// type a bit, make a line break and type again
const $firstTextElement = inner$('div span').first();
2020-06-05 21:18:58 +00:00
$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 hasULElement = $newSecondLine.find('ul li').length === 1;
2020-06-05 21:18:58 +00:00
expect(hasULElement).to.be(true);
expect($newSecondLine.text()).to.be('line 2');
2020-06-05 21:18:58 +00:00
done();
});
});
});
describe('Pressing Tab in an UL increases and decreases indentation', function () {
// create a new pad before each test run
beforeEach(function (cb) {
2020-06-05 21:18:58 +00:00
helper.newPad(cb);
this.timeout(60000);
});
it('indent and de-indent list item with keypress', function (done) {
const inner$ = helper.padInner$;
const chrome$ = helper.padChrome$;
2020-06-05 21:18:58 +00:00
// get the first text element out of the inner iframe
const $firstTextElement = inner$('div').first();
2020-06-05 21:18:58 +00:00
// select this text element
2020-06-05 21:18:58 +00:00
$firstTextElement.sendkeys('{selectall}');
const $insertorderedlistButton = chrome$('.buttonicon-insertunorderedlist');
2020-06-05 21:18:58 +00:00
$insertorderedlistButton.click();
const e = inner$.Event(helper.evtType);
2020-06-05 21:18:58 +00:00
e.keyCode = 9; // tab
inner$('#innerdocbody').trigger(e);
2020-06-05 21:18:58 +00:00
expect(inner$('div').first().find('.list-bullet2').length === 1).to.be(true);
2020-06-05 21:18:58 +00:00
e.shiftKey = true; // shift
e.keyCode = 9; // tab
inner$('#innerdocbody').trigger(e);
2020-06-05 21:18:58 +00:00
helper.waitFor(() => inner$('div').first().find('.list-bullet1').length === 1).done(done);
2020-06-05 21:18:58 +00:00
});
});
describe('Pressing indent/outdent button in an UL increases and decreases indentation and bullet / ol formatting', function () {
// create a new pad before each test run
beforeEach(function (cb) {
2020-06-05 21:18:58 +00:00
helper.newPad(cb);
this.timeout(60000);
});
it('indent and de-indent list item with indent button', function (done) {
const inner$ = helper.padInner$;
const chrome$ = helper.padChrome$;
2020-06-05 21:18:58 +00:00
// get the first text element out of the inner iframe
const $firstTextElement = inner$('div').first();
2020-06-05 21:18:58 +00:00
// select this text element
2020-06-05 21:18:58 +00:00
$firstTextElement.sendkeys('{selectall}');
const $insertunorderedlistButton = chrome$('.buttonicon-insertunorderedlist');
2020-06-05 21:18:58 +00:00
$insertunorderedlistButton.click();
const $indentButton = chrome$('.buttonicon-indent');
2020-06-05 21:18:58 +00:00
$indentButton.click(); // make it indented twice
expect(inner$('div').first().find('.list-bullet2').length === 1).to.be(true);
const $outdentButton = chrome$('.buttonicon-outdent');
2020-06-05 21:18:58 +00:00
$outdentButton.click(); // make it deindented to 1
helper.waitFor(() => inner$('div').first().find('.list-bullet1').length === 1).done(done);
2020-06-05 21:18:58 +00:00
});
});