pulsar/spec/workspace-center-spec.js
Jason Rudolph a49203504c
🐛 Add missing onDidAddTextEditor method to WorkspaceCenter
WorkspaceCenter's observeTextEditors method calls
this.onDidAddTextEditor, but WorkspaceCenter didn't have an
onDidAddTextEditor method. This commit adds a test for
observeTextEditors and it adds the missing onDidAddTextEditor method to
make the test pass.
2017-05-25 17:24:07 -04:00

32 lines
1.2 KiB
JavaScript

/** @babel */
const TextEditor = require('../src/text-editor')
import {it, fit, ffit, fffit, beforeEach, afterEach} from './async-spec-helpers'
describe('WorkspaceCenter', () => {
describe('.observeTextEditors()', () => {
it('invokes the observer with current and future text editors', () => {
const workspaceCenter = atom.workspace.getCenter()
const pane = workspaceCenter.getActivePane()
const observed = []
const editorAddedBeforeRegisteringObserver = new TextEditor()
const nonEditorItemAddedBeforeRegisteringObserver = document.createElement('div')
pane.activateItem(editorAddedBeforeRegisteringObserver)
pane.activateItem(nonEditorItemAddedBeforeRegisteringObserver)
workspaceCenter.observeTextEditors(editor => observed.push(editor))
const editorAddedAfterRegisteringObserver = new TextEditor()
const nonEditorItemAddedAfterRegisteringObserver = document.createElement('div')
pane.activateItem(editorAddedAfterRegisteringObserver)
pane.activateItem(nonEditorItemAddedAfterRegisteringObserver)
expect(observed).toEqual(
[editorAddedBeforeRegisteringObserver, editorAddedAfterRegisteringObserver]
)
})
})
})