Don't use workspace's itemLocationStore in tests

This commit is contained in:
Max Brunsfeld
2017-04-07 15:30:44 -07:00
parent daa449e8d5
commit 48336fb95e
3 changed files with 14 additions and 4 deletions

View File

@@ -294,6 +294,15 @@ describe('Workspace', () => {
})
describe('when the active pane does not have an editor for the given uri', () => {
beforeEach(() => {
atom.workspace.enablePersistence = true
})
afterEach(async () => {
await atom.workspace.itemLocationStore.clear()
atom.workspace.enablePersistence = false
})
it('adds and activates a new editor for the given path on the active pane', () => {
let editor = null
waitsForPromise(() => workspace.open('a').then(o => { editor = o }))

View File

@@ -173,7 +173,7 @@ class AtomEnvironment extends Model
@workspace = new Workspace({
@config, @project, packageManager: @packages, grammarRegistry: @grammars, deserializerManager: @deserializers,
notificationManager: @notifications, @applicationDelegate, viewRegistry: @views, assert: @assert.bind(this),
textEditorRegistry: @textEditors, styleManager: @styles
textEditorRegistry: @textEditors, styleManager: @styles, @enablePersistence
})
@themes.workspace = @workspace

View File

@@ -42,6 +42,7 @@ module.exports = class Workspace extends Model {
this.didActivatePaneContainer = this.didActivatePaneContainer.bind(this)
this.didHideDock = this.didHideDock.bind(this)
this.enablePersistence = params.enablePersistence
this.packageManager = params.packageManager
this.config = params.config
this.project = params.project
@@ -359,9 +360,9 @@ module.exports = class Workspace extends Model {
for (const paneContainer of this.getPaneContainers()) {
paneContainer.observePanes(pane => {
pane.onDidAddItem(({item}) => {
if (typeof item.getURI === 'function') {
if (typeof item.getURI === 'function' && this.enablePersistence) {
const uri = item.getURI()
if (uri != null) {
if (uri) {
const location = paneContainer.getLocation()
let defaultLocation
if (typeof item.getDefaultLocation === 'function') {
@@ -782,7 +783,7 @@ module.exports = class Workspace extends Model {
pane = options.pane
} else {
let location = options.location
if (!location && !options.split && uri) {
if (!location && !options.split && uri && this.enablePersistence) {
location = await this.itemLocationStore.load(uri)
}
if (!location && typeof item.getDefaultLocation === 'function') {