mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
a49203504c
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.
32 lines
1.2 KiB
JavaScript
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]
|
|
)
|
|
})
|
|
})
|
|
})
|