2021-02-01 20:23:14 +00:00
|
|
|
'use strict';
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
describe('undo button then redo button', function () {
|
|
|
|
beforeEach(function (cb) {
|
2012-10-09 00:30:46 +00:00
|
|
|
helper.newPad(cb); // creates a new pad
|
2012-11-01 23:19:59 +00:00
|
|
|
this.timeout(60000);
|
2012-10-09 00:30:46 +00:00
|
|
|
});
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
it('redo some typing with button', function (done) {
|
|
|
|
const inner$ = helper.padInner$;
|
|
|
|
const chrome$ = helper.padChrome$;
|
2020-03-24 00:04:24 +00:00
|
|
|
|
2012-10-09 00:30:46 +00:00
|
|
|
// get the first text element inside the editable space
|
2020-11-23 18:21:51 +00:00
|
|
|
const $firstTextElement = inner$('div span').first();
|
|
|
|
const originalValue = $firstTextElement.text(); // get the original value
|
|
|
|
const newString = 'Foo';
|
2012-10-09 00:30:46 +00:00
|
|
|
|
2012-10-28 18:19:16 +00:00
|
|
|
$firstTextElement.sendkeys(newString); // send line 1 to the pad
|
2020-11-23 18:21:51 +00:00
|
|
|
const modifiedValue = $firstTextElement.text(); // get the modified value
|
2012-10-09 00:30:46 +00:00
|
|
|
expect(modifiedValue).not.to.be(originalValue); // expect the value to change
|
|
|
|
|
2012-10-28 18:19:16 +00:00
|
|
|
// get undo and redo buttons
|
2020-11-23 18:21:51 +00:00
|
|
|
const $undoButton = chrome$('.buttonicon-undo');
|
|
|
|
const $redoButton = chrome$('.buttonicon-redo');
|
2012-10-09 00:30:46 +00:00
|
|
|
// click the buttons
|
2012-10-28 18:19:16 +00:00
|
|
|
$undoButton.click(); // removes foo
|
|
|
|
$redoButton.click(); // resends foo
|
2012-10-09 00:30:46 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.waitFor(() => inner$('div span').first().text() === newString).done(() => {
|
|
|
|
const finalValue = inner$('div').first().text();
|
2012-10-09 00:30:46 +00:00
|
|
|
expect(finalValue).to.be(modifiedValue); // expect the value to change
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2013-03-13 18:00:04 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
it('redo some typing with keypress', function (done) {
|
|
|
|
const inner$ = helper.padInner$;
|
2013-03-13 18:00:04 +00:00
|
|
|
|
|
|
|
// get the first text element inside the editable space
|
2020-11-23 18:21:51 +00:00
|
|
|
const $firstTextElement = inner$('div span').first();
|
|
|
|
const originalValue = $firstTextElement.text(); // get the original value
|
|
|
|
const newString = 'Foo';
|
2013-03-13 18:00:04 +00:00
|
|
|
|
|
|
|
$firstTextElement.sendkeys(newString); // send line 1 to the pad
|
2020-11-23 18:21:51 +00:00
|
|
|
const modifiedValue = $firstTextElement.text(); // get the modified value
|
2013-03-13 18:00:04 +00:00
|
|
|
expect(modifiedValue).not.to.be(originalValue); // expect the value to change
|
|
|
|
|
2021-02-01 20:23:14 +00:00
|
|
|
let e = inner$.Event(helper.evtType);
|
2013-03-13 18:00:04 +00:00
|
|
|
e.ctrlKey = true; // Control key
|
|
|
|
e.which = 90; // z
|
2020-11-23 18:21:51 +00:00
|
|
|
inner$('#innerdocbody').trigger(e);
|
2013-03-13 18:00:04 +00:00
|
|
|
|
2021-02-01 20:23:14 +00:00
|
|
|
e = inner$.Event(helper.evtType);
|
2013-03-13 18:00:04 +00:00
|
|
|
e.ctrlKey = true; // Control key
|
|
|
|
e.which = 121; // y
|
2020-11-23 18:21:51 +00:00
|
|
|
inner$('#innerdocbody').trigger(e);
|
2013-03-13 18:00:04 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.waitFor(() => inner$('div span').first().text() === newString).done(() => {
|
|
|
|
const finalValue = inner$('div').first().text();
|
2013-03-13 18:00:04 +00:00
|
|
|
expect(finalValue).to.be(modifiedValue); // expect the value to change
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2012-10-09 00:30:46 +00:00
|
|
|
});
|