forked from emmetio/emmet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditPoints.js
47 lines (36 loc) · 1.33 KB
/
editPoints.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var assert = require('assert');
var editor = require('../stubs/editor');
var action = require('../../lib/action/editPoints');
describe('Move to Edit Point action', function() {
var content = '<a href="">\n\t<b></b>\n\t\n</a>';
it('should move caret to next point', function() {
editor.replaceContent(content);
editor.setCaretPos(0);
var run = function() {
return action.nextEditPointAction(editor);
};
run();
assert.equal(editor.getCaretPos(), 9, 'Movet caret into empty attribute (forward)');
run();
assert.equal(editor.getCaretPos(), 16, 'Movet caret into <b> tag (forward)');
run();
assert.equal(editor.getCaretPos(), 22, 'Movet caret into empty line (forward)');
run();
assert.equal(editor.getCaretPos(), 22, 'No movement (forward)');
});
it('should move caret to previous point', function() {
editor.replaceContent(content);
editor.setCaretPos(content.length);
var run = function() {
return action.previousEditPointAction(editor);
};
run();
assert.equal(editor.getCaretPos(), 22, 'Movet caret into empty line (backward)');
run();
assert.equal(editor.getCaretPos(), 16, 'Movet caret into <b> tag (backward)');
run();
assert.equal(editor.getCaretPos(), 9, 'Movet caret into empty attribute (backward)');
run();
assert.equal(editor.getCaretPos(), 9, 'No movement (backward)');
});
});