Hoist out a util for creating a mock Editor given an already-created

document, so JS code hints unit tests can share SpecRunnerUtils' mock-Editor
creation code instead of duplicating it.
This commit is contained in:
Peter Flynn committed 2013-05-21 17:18:20 -07:00
1 parent 246d72ca7a
commit 427914df4b
2 files changed
+21 -23

No files matched your search

@@ -49,26 +49,15 @@ define(function (require, exports, module) {
DocumentManager.setCurrentDocument(doc);
});
});
/**
* Returns an Editor suitable for use in isolation, given a Document. (Unlike
* SpecRunnerUtils.createMockEditor(), which is given text and creates the Document
* for you).
* Returns an Editor suitable for use in isolation, given a Document.
*
* @param {Document} doc - the document to be contained by the new Editor
* @return {Editor} - the mock editor object
*/
function createMockEditor(doc) {
// Initialize EditorManager
var $editorHolder = $("<div id='mock-editor-holder'/>");
EditorManager.setEditorHolder($editorHolder);
$("body").append($editorHolder);
// create Editor instance
var editor = new Editor(doc, true, $editorHolder.get(0));
EditorManager._notifyActiveEditorChanged(editor);
return editor;
return SpecRunnerUtils.createMockEditorForDocument(doc);
}
describe("JavaScript Code Hinting", function () {