1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- QUnit.module('creta_keyboard', function() {
- QUnit.test('new line', function(assert) {
-
- initial_values();
-
- first_div.innerText = "Lorem Ipsum";
- let selection = window.getSelection();
- let range = document.createRange();
- range.selectNodeContents(first_div);
- selection.removeAllRanges();
- selection.addRange(range);
- selection.collapseToEnd();
-
- first_div.dispatchEvent(new KeyboardEvent('keydown', {
- code: 'Enter',
- key: 'Enter',
- charCode: 13,
- keyCode: 13,
- view: window,
- bubbles: true
- }));
- assert.equal(visual_editor.get_text(), "<div>Lorem Ipsum</div>\n<div></div>");
-
- });
-
- QUnit.test('backspace', function(assert) {
-
- initial_values();
- first_div.innerText = "Lorem Ipsum";
-
- let selection = window.getSelection();
- let range = document.createRange();
- range.selectNodeContents(first_div);
- selection.removeAllRanges();
- selection.addRange(range);
- selection.collapseToEnd();
-
- first_div.dispatchEvent(new KeyboardEvent('keydown', {
- code: 'Enter',
- key: 'Enter',
- charCode: 13,
- keyCode: 13,
- view: window,
- bubbles: true
- }));
-
- selection = window.getSelection();
- range = document.createRange();
- range.selectNodeContents(first_div);
- selection.removeAllRanges();
- selection.addRange(range);
-
- first_div.nextSibling.dispatchEvent(new KeyboardEvent('keydown', {
- code: 'Backspace',
- key: 'Backspace',
- charCode: 0,
- keyCode: 8,
- view: window,
- bubbles: true
- }));
-
- assert.equal(visual_editor.get_text(), "<div>Lorem Ipsum</div>");
-
- });
- });
-
|