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('
'));
ok(editor.plugins.autosave.isEmpty(''));
ok(editor.plugins.autosave.isEmpty('
'));
ok(editor.plugins.autosave.isEmpty('\t
'));
ok(editor.plugins.autosave.isEmpty('
'));
ok(editor.plugins.autosave.isEmpty('
'));
ok(editor.plugins.autosave.isEmpty('
'));
ok(editor.plugins.autosave.isEmpty('
'));
ok(editor.plugins.autosave.isEmpty('
'));
ok(editor.plugins.autosave.isEmpty('
'));
});
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('X
'));
ok(!editor.plugins.autosave.isEmpty(' X
'));
ok(!editor.plugins.autosave.isEmpty('\tX
'));
ok(!editor.plugins.autosave.isEmpty('
X
'));
ok(!editor.plugins.autosave.isEmpty('
X
'));
ok(!editor.plugins.autosave.isEmpty('
X
'));
ok(!editor.plugins.autosave.isEmpty('
X
'));
ok(!editor.plugins.autosave.isEmpty('
X
'));
ok(!editor.plugins.autosave.isEmpty('
X
'));
ok(!editor.plugins.autosave.isEmpty(''));
ok(!editor.plugins.autosave.isEmpty(''));
});
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(), 'X
');
});