mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 07:28:08 +03:00
Test deserialization in terms of user-observable functionality
- Rework serialization/deserialization test - Move simulateReload function so that it can be used in multiple describe blocks
This commit is contained in:
parent
9629caefb7
commit
44a2be7c9d
@ -31,35 +31,35 @@ describe('Workspace', () => {
|
||||
|
||||
afterEach(() => temp.cleanupSync())
|
||||
|
||||
describe('serialization', () => {
|
||||
const simulateReload = () => {
|
||||
const workspaceState = atom.workspace.serialize()
|
||||
const projectState = atom.project.serialize({isUnloading: true})
|
||||
atom.workspace.destroy()
|
||||
atom.project.destroy()
|
||||
atom.project = new Project({
|
||||
notificationManager: atom.notifications,
|
||||
packageManager: atom.packages,
|
||||
confirm: atom.confirm.bind(atom),
|
||||
applicationDelegate: atom.applicationDelegate
|
||||
})
|
||||
atom.project.deserialize(projectState)
|
||||
atom.workspace = new Workspace({
|
||||
config: atom.config,
|
||||
project: atom.project,
|
||||
packageManager: atom.packages,
|
||||
grammarRegistry: atom.grammars,
|
||||
styleManager: atom.styles,
|
||||
deserializerManager: atom.deserializers,
|
||||
notificationManager: atom.notifications,
|
||||
applicationDelegate: atom.applicationDelegate,
|
||||
viewRegistry: atom.views,
|
||||
assert: atom.assert.bind(atom),
|
||||
textEditorRegistry: atom.textEditors
|
||||
})
|
||||
return atom.workspace.deserialize(workspaceState, atom.deserializers)
|
||||
}
|
||||
const simulateReload = () => {
|
||||
const workspaceState = workspace.serialize()
|
||||
const projectState = atom.project.serialize({isUnloading: true})
|
||||
workspace.destroy()
|
||||
atom.project.destroy()
|
||||
atom.project = new Project({
|
||||
notificationManager: atom.notifications,
|
||||
packageManager: atom.packages,
|
||||
confirm: atom.confirm.bind(atom),
|
||||
applicationDelegate: atom.applicationDelegate
|
||||
})
|
||||
atom.project.deserialize(projectState)
|
||||
workspace = atom.workspace = new Workspace({
|
||||
config: atom.config,
|
||||
project: atom.project,
|
||||
packageManager: atom.packages,
|
||||
grammarRegistry: atom.grammars,
|
||||
styleManager: atom.styles,
|
||||
deserializerManager: atom.deserializers,
|
||||
notificationManager: atom.notifications,
|
||||
applicationDelegate: atom.applicationDelegate,
|
||||
viewRegistry: atom.views,
|
||||
assert: atom.assert.bind(atom),
|
||||
textEditorRegistry: atom.textEditors
|
||||
})
|
||||
return workspace.deserialize(workspaceState, atom.deserializers)
|
||||
}
|
||||
|
||||
describe('serialization', () => {
|
||||
describe('when the workspace contains text editors', () => {
|
||||
it('constructs the view with the same panes', () => {
|
||||
const pane1 = atom.workspace.getActivePane()
|
||||
@ -120,20 +120,6 @@ describe('Workspace', () => {
|
||||
expect(atom.workspace.getTextEditors().length).toBe(0)
|
||||
})
|
||||
})
|
||||
|
||||
it('remembers whether the workspace had an active text editor', async () => {
|
||||
await atom.workspace.open('../sample.txt')
|
||||
expect(atom.workspace.hasActiveTextEditor).toBe(true)
|
||||
|
||||
simulateReload()
|
||||
expect(atom.workspace.hasActiveTextEditor).toBe(true)
|
||||
|
||||
atom.workspace.getActivePane().destroy()
|
||||
expect(atom.workspace.hasActiveTextEditor).toBe(false)
|
||||
|
||||
simulateReload()
|
||||
expect(atom.workspace.hasActiveTextEditor).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('::open(itemOrURI, options)', () => {
|
||||
@ -1518,6 +1504,17 @@ describe('Workspace', () => {
|
||||
|
||||
expect(observed).toEqual([])
|
||||
})
|
||||
|
||||
it('invokes the observer when closing the one and only text editor after deserialization', async () => {
|
||||
pane.activateItem(new TextEditor())
|
||||
|
||||
simulateReload()
|
||||
|
||||
const editor = workspace.getActiveTextEditor()
|
||||
workspace.observeActiveTextEditor(editor => observed.push(editor))
|
||||
workspace.closeActivePaneItemOrEmptyPaneOrWindow()
|
||||
expect(observed).toEqual([editor, undefined])
|
||||
})
|
||||
})
|
||||
|
||||
describe('when an editor is destroyed', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user