forked from tinymce/tinymce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautosave.js
74 lines (59 loc) · 2.35 KB
/
autosave.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
module("tinymce.plugins.Autosave", {
setupModule: function() {
QUnit.stop();
tinymce.init({
selector: "textarea",
add_unload_trigger: false,
skin: false,
plugins: 'autosave',
autosave_ask_before_unload: false,
init_instance_callback: function(ed) {
window.editor = ed;
editor.plugins.autosave.removeDraft();
QUnit.start();
}
});
}
});
test("isEmpty true", function() {
ok(editor.plugins.autosave.isEmpty(''));
ok(editor.plugins.autosave.isEmpty(' '));
ok(editor.plugins.autosave.isEmpty('\t\t\t'));
ok(editor.plugins.autosave.isEmpty('<p id="x"></p>'));
ok(editor.plugins.autosave.isEmpty('<p></p>'));
ok(editor.plugins.autosave.isEmpty('<p> </p>'));
ok(editor.plugins.autosave.isEmpty('<p>\t</p>'));
ok(editor.plugins.autosave.isEmpty('<p><br></p>'));
ok(editor.plugins.autosave.isEmpty('<p><br /></p>'));
ok(editor.plugins.autosave.isEmpty('<p><br data-mce-bogus="true" /></p>'));
ok(editor.plugins.autosave.isEmpty('<p><br><br></p>'));
ok(editor.plugins.autosave.isEmpty('<p><br /><br /></p>'));
ok(editor.plugins.autosave.isEmpty('<p><br data-mce-bogus="true" /><br data-mce-bogus="true" /></p>'));
});
test("isEmpty false", function() {
ok(!editor.plugins.autosave.isEmpty('X'));
ok(!editor.plugins.autosave.isEmpty(' X'));
ok(!editor.plugins.autosave.isEmpty('\t\t\tX'));
ok(!editor.plugins.autosave.isEmpty('<p>X</p>'));
ok(!editor.plugins.autosave.isEmpty('<p> X</p>'));
ok(!editor.plugins.autosave.isEmpty('<p>\tX</p>'));
ok(!editor.plugins.autosave.isEmpty('<p><br>X</p>'));
ok(!editor.plugins.autosave.isEmpty('<p><br />X</p>'));
ok(!editor.plugins.autosave.isEmpty('<p><br data-mce-bogus="true" />X</p>'));
ok(!editor.plugins.autosave.isEmpty('<p><br><br>X</p>'));
ok(!editor.plugins.autosave.isEmpty('<p><br /><br />X</p>'));
ok(!editor.plugins.autosave.isEmpty('<p><br data-mce-bogus="true" /><br data-mce-bogus="true" />X</p>'));
ok(!editor.plugins.autosave.isEmpty('<h1></h1>'));
ok(!editor.plugins.autosave.isEmpty('<img src="x" />'));
});
test("hasDraft/storeDraft/restoreDraft", function() {
ok(!editor.plugins.autosave.hasDraft());
editor.setContent('X');
editor.undoManager.add();
editor.plugins.autosave.storeDraft();
ok(editor.plugins.autosave.hasDraft());
editor.setContent('Y');
editor.undoManager.add();
editor.plugins.autosave.restoreDraft();
equal(editor.getContent(), '<p>X</p>');
});