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

38 lines
1.3 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("undo some typing", 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
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();
});
});
});