Skip to content

Commit

Permalink
GH-3257: added location hash test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattias Wikstrom committed Oct 17, 2017
1 parent 0084d5c commit 6cae659
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/plugins/autosave/src/test/js/browser/AutoSavePluginTest.js
Expand Up @@ -4,10 +4,13 @@ asynctest(
'ephox.agar.api.Pipeline',
'ephox.mcagar.api.LegacyUnit',
'ephox.mcagar.api.TinyLoader',
'global!document',
'global!history',
'global!window',
'tinymce.plugins.autosave.Plugin',
'tinymce.themes.modern.Theme'
],
function (Pipeline, LegacyUnit, TinyLoader, Plugin, Theme) {
function (Pipeline, LegacyUnit, TinyLoader, document, history, window, Plugin, Theme) {
var success = arguments[arguments.length - 2];
var failure = arguments[arguments.length - 1];
var suite = LegacyUnit.createSuite();
Expand Down Expand Up @@ -69,6 +72,21 @@ asynctest(

editor.plugins.autosave.restoreDraft();
LegacyUnit.equal(editor.getContent(), '<p>X</p>');
editor.plugins.autosave.removeDraft();
});

suite.test("recognises location hash change", function (editor) {
LegacyUnit.equal(editor.plugins.autosave.hasDraft(), false);

editor.setContent('X');
editor.undoManager.add();
editor.plugins.autosave.storeDraft();

window.location.hash = "test";

LegacyUnit.equal(editor.plugins.autosave.hasDraft(), false);

history.replaceState("", document.title, window.location.pathname + window.location.search);
});

TinyLoader.setup(function (editor, onSuccess, onFailure) {
Expand Down

0 comments on commit 6cae659

Please sign in to comment.