Spec for an item with a deferred TextEditor
MODIFY
spec/find-spec.js
spec/find-spec.js
@@ -2,6 +2,7 @@ const {it, fit, ffit, beforeEach, afterEach} = require('./async-spec-helpers') /
const BufferSearch = require('../lib/buffer-search')
const EmbeddedEditorItem = require('./item/embedded-editor-item')
+const DeferredEditorItem = require('./item/deferred-editor-item');
const UnrecognizedItem = require('./item/unrecognized-item');
describe('Find', () => {
@@ -9,6 +10,7 @@ describe('Find', () => {
beforeEach(async () => {
atom.workspace.addOpener(EmbeddedEditorItem.opener)
atom.workspace.addOpener(UnrecognizedItem.opener)
+ atom.workspace.addOpener(DeferredEditorItem.opener)
const activationPromise = atom.packages.activatePackage('find-and-replace')
atom.commands.dispatch(atom.views.getView(atom.workspace), 'find-and-replace:show')
@@ -30,6 +32,17 @@ describe('Find', () => {
expect(BufferSearch.prototype.setEditor).toHaveBeenCalledWith(embedded.refs.theEditor)
})
+ it("sets the find model's editor to an embedded text editor after activation", async () => {
+ const deferred = await atom.workspace.open(DeferredEditorItem.uri)
+ expect(BufferSearch.prototype.setEditor).not.toHaveBeenCalled()
+
+ await deferred.showEditor()
+ expect(BufferSearch.prototype.setEditor).toHaveBeenCalledWith(deferred.refs.theEditor)
+
+ await deferred.hideEditor()
+ expect(BufferSearch.prototype.setEditor).toHaveBeenCalledWith(null)
+ })
+
it("sets the find model's editor to null if a non-editor is focused", async () => {
await atom.workspace.open(UnrecognizedItem.uri)
expect(BufferSearch.prototype.setEditor).toHaveBeenCalledWith(null)

Spec for an item with a deferred TextEditor