etherpad-lite/tests/frontend/specs/redo.js

77 lines
2.6 KiB
JavaScript
Raw Normal View History

2012-10-28 19:19:16 +01:00
describe("undo button then redo button", function(){
2012-10-09 02:30:46 +02:00
beforeEach(function(cb){
helper.newPad(cb); // creates a new pad
2012-11-02 00:19:59 +01:00
this.timeout(60000);
2012-10-09 02:30:46 +02:00
});
it("redo some typing with button", function(done){
2012-10-09 02:30:46 +02:00
var inner$ = helper.padInner$;
var chrome$ = helper.padChrome$;
// get the first text element inside the editable space
var $firstTextElement = inner$("div span").first();
var originalValue = $firstTextElement.text(); // get the original value
2012-10-28 19:19:16 +01:00
var newString = "Foo";
2012-10-09 02:30:46 +02:00
2012-10-28 19:19:16 +01:00
$firstTextElement.sendkeys(newString); // send line 1 to the pad
2012-10-09 02:30:46 +02:00
var modifiedValue = $firstTextElement.text(); // get the modified value
expect(modifiedValue).not.to.be(originalValue); // expect the value to change
2012-10-28 19:19:16 +01:00
// get undo and redo buttons
2012-10-09 02:30:46 +02:00
var $undoButton = chrome$(".buttonicon-undo");
var $redoButton = chrome$(".buttonicon-redo");
// click the buttons
2012-10-28 19:19:16 +01:00
$undoButton.click(); // removes foo
$redoButton.click(); // resends foo
2012-10-09 02:30:46 +02:00
helper.waitFor(function(){
2012-10-28 19:19:16 +01:00
console.log(inner$("div span").first().text());
return inner$("div span").first().text() === newString;
2012-10-09 02:30:46 +02:00
}).done(function(){
2012-10-28 19:19:16 +01:00
var finalValue = inner$("div").first().text();
2012-10-09 02:30:46 +02:00
expect(finalValue).to.be(modifiedValue); // expect the value to change
done();
});
});
it("redo some typing with keypress", function(done){
var inner$ = helper.padInner$;
var chrome$ = helper.padChrome$;
// get the first text element inside the editable space
var $firstTextElement = inner$("div span").first();
var originalValue = $firstTextElement.text(); // get the original value
var newString = "Foo";
$firstTextElement.sendkeys(newString); // send line 1 to the pad
var modifiedValue = $firstTextElement.text(); // get the modified value
expect(modifiedValue).not.to.be(originalValue); // expect the value to change
2015-01-21 16:21:15 +01:00
if(inner$(window)[0].bowser.firefox || inner$(window)[0].bowser.modernIE){ // if it's a mozilla or IE
2013-03-14 18:22:58 +01:00
var evtType = "keypress";
2013-03-14 18:36:54 +01:00
}else{
var evtType = "keydown";
}
var e = inner$.Event(evtType);
e.ctrlKey = true; // Control key
e.which = 90; // z
inner$("#innerdocbody").trigger(e);
2013-03-14 17:52:20 +01:00
var e = inner$.Event(evtType);
e.ctrlKey = true; // Control key
e.which = 121; // y
inner$("#innerdocbody").trigger(e);
helper.waitFor(function(){
console.log(inner$("div span").first().text());
return inner$("div span").first().text() === newString;
}).done(function(){
var finalValue = inner$("div").first().text();
expect(finalValue).to.be(modifiedValue); // expect the value to change
done();
});
});
2012-10-09 02:30:46 +02:00
});