forked from mycolorway/simditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core-spec.js
54 lines (53 loc) · 2.01 KB
/
core-spec.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
48
49
50
51
52
53
54
(function() {
describe('A Simditor instance', function() {
var editor;
editor = null;
beforeEach(function() {
return editor = spec.generateSimditor();
});
afterEach(function() {
spec.destroySimditor();
return editor = null;
});
it('should render specific layout', function() {
var $simditor;
$simditor = $('.simditor');
expect($simditor.length).toBe(1);
expect($simditor.find('> .simditor-wrapper > .simditor-body').length).toBe(1);
expect($simditor.find('> .simditor-wrapper > .simditor-placeholder').length).toBe(1);
expect($simditor.find('> .simditor-wrapper > textarea#editor').length).toBe(1);
expect(editor.el.is('.simditor')).toBe(true);
expect(editor.body.is('.simditor-body')).toBe(true);
return expect(editor.wrapper.is('.simditor-wrapper')).toBe(true);
});
it('should reset to default after destroyed', function() {
var $textarea;
$textarea = $('textarea#editor');
if (editor != null) {
editor.destroy();
}
expect($('.simditor').length).toBe(0);
expect($textarea.length).toBe(1);
return expect($textarea.data('simditor')).toBeUndefined();
});
it('should set formatted value to editor\'s body after calling setValue', function() {
var tmpHtml;
tmpHtml = '<p id="flag">test format</p>';
editor.setValue(tmpHtml);
return expect($.trim(editor.body.html())).toBe('<p>test format</p>');
});
it('should get formatted editor\'s value by calling getValue', function() {
var tmpHtml;
tmpHtml = '<p id="flag">test format</p>';
editor.body.html(tmpHtml);
return expect(editor.getValue()).toBe('<p>test format</p>');
});
return it('should lose focus after calling blur', function() {
editor.focus();
editor.blur();
expect(document.activeElement).not.toBe(editor.body[0]);
expect(editor.selection.range()).toBe(null);
return expect(editor.inputManager.focused).toBe(false);
});
});
}).call(this);