mirror of
				https://github.com/ether/etherpad-lite.git
				synced 2025-10-31 16:21:11 +01:00 
			
		
		
		
	working keystroke delete check
This commit is contained in:
		
							parent
							
								
									aa41ebcd6d
								
							
						
					
					
						commit
						339ee6d2e0
					
				| @ -11,38 +11,28 @@ describe("delete keystroke", function(){ | |||||||
|     //get the first text element out of the inner iframe
 |     //get the first text element out of the inner iframe
 | ||||||
|     var firstTextElement = $inner.find("div").first(); |     var firstTextElement = $inner.find("div").first(); | ||||||
|      |      | ||||||
|     //select this text element
 |  | ||||||
|     testHelper.selectText(firstTextElement[0]); |  | ||||||
| 
 |  | ||||||
|     // get the original length of this element
 |     // get the original length of this element
 | ||||||
|     var elementLength = firstTextElement.html().length; |     var elementLength = firstTextElement.html().length; | ||||||
|     console.log(elementLength); |  | ||||||
| 
 | 
 | ||||||
|     //get the bold keystroke and click it
 |     // get the original string value minus the last char
 | ||||||
|     // var $deletekeystroke = testHelper.$getPadChrome().find(".keystrokeicon-delete");
 |     var originalTextValue = firstTextElement.text(); | ||||||
|  |     originalTextValue = originalTextValue.substring(0, originalTextValue.length -1); | ||||||
| 
 | 
 | ||||||
|     //put the cursor in the pad
 |     // simulate key presses to delete content
 | ||||||
|     var press = $.Event("keypress"); |     firstTextElement.sendkeys('{leftarrow}'); // simulate a keypress of the left arrow key
 | ||||||
|     press.ctrlKey = false; |     firstTextElement.sendkeys('{del}'); // simulate a keypress of delete
 | ||||||
|     press.which = 46; // 46 is delete key
 |  | ||||||
|     firstTextElement.trigger(press); // simulate a keypress of delete
 |  | ||||||
|     press.which = 37; // 37 is left key taking user to first place in pad.
 |  | ||||||
|     firstTextElement.trigger(press); // simulate a keypress of left key
 |  | ||||||
| 
 | 
 | ||||||
|     //ace creates a new dom element when you press a keystroke, so just get the first text element again
 |     //ace creates a new dom element when you press a keystroke, so just get the first text element again
 | ||||||
|     var newFirstTextElement = $inner.find("div").first(); |     var newFirstTextElement = $inner.find("div").first(); | ||||||
|      |      | ||||||
|     // is there a <b> element now?
 |  | ||||||
|     // var isdelete = newFirstTextElement.find("i").length === 1;
 |  | ||||||
| 
 |  | ||||||
|     // get the new length of this element
 |     // get the new length of this element
 | ||||||
|     var newElementLength = newFirstTextElement.html().length; |     var newElementLength = newFirstTextElement.html().length; | ||||||
|     console.log(newElementLength); |  | ||||||
| 
 | 
 | ||||||
|     //expect it to be one char less
 |     //expect it to be one char less in length
 | ||||||
|     expect(newElementLength).to.be((elementLength-1)); |     expect(newElementLength).to.be((elementLength-1)); | ||||||
| 
 | 
 | ||||||
|     //make sure the text hasn't changed
 |     //make sure the text has changed correctly
 | ||||||
|     expect(newFirstTextElement.text()).to.eql(firstTextElement.text()); |     expect(newFirstTextElement.text()).to.eql(originalTextValue); | ||||||
|  | 
 | ||||||
|   }); |   }); | ||||||
| }); | }); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user