2014-09-18 23:42:13 +04:00
|
|
|
PaneContainer = require '../src/pane-container'
|
2014-01-14 00:29:00 +04:00
|
|
|
PaneView = require '../src/pane-view'
|
2014-02-24 05:19:00 +04:00
|
|
|
fs = require 'fs-plus'
|
2014-11-26 01:35:22 +03:00
|
|
|
{Emitter, Disposable} = require 'event-kit'
|
2014-11-25 23:55:50 +03:00
|
|
|
{$, View} = require '../src/space-pen-extensions'
|
2013-10-21 17:20:19 +04:00
|
|
|
path = require 'path'
|
|
|
|
temp = require 'temp'
|
2013-02-18 21:45:02 +04:00
|
|
|
|
2014-01-14 00:29:00 +04:00
|
|
|
describe "PaneView", ->
|
2014-09-30 22:54:50 +04:00
|
|
|
[container, containerModel, view1, view2, editor1, editor2, pane, paneModel, deserializerDisposable] = []
|
2013-02-18 21:45:02 +04:00
|
|
|
|
2013-06-21 02:57:34 +04:00
|
|
|
class TestView extends View
|
|
|
|
@deserialize: ({id, text}) -> new TestView({id, text})
|
2013-07-01 21:52:40 +04:00
|
|
|
@content: ({id, text}) -> @div class: 'test-view', id: id, tabindex: -1, text
|
2013-06-21 02:57:34 +04:00
|
|
|
initialize: ({@id, @text}) ->
|
2014-09-11 22:28:21 +04:00
|
|
|
@emitter = new Emitter
|
2013-06-21 02:57:34 +04:00
|
|
|
serialize: -> { deserializer: 'TestView', @id, @text }
|
|
|
|
getUri: -> @id
|
2014-01-08 04:23:29 +04:00
|
|
|
isEqual: (other) -> other? and @id == other.id and @text == other.text
|
2014-09-11 22:28:21 +04:00
|
|
|
changeTitle: ->
|
|
|
|
@emitter.emit 'did-change-title', 'title'
|
|
|
|
onDidChangeTitle: (callback) ->
|
|
|
|
@emitter.on 'did-change-title', callback
|
2014-11-26 01:35:22 +03:00
|
|
|
onDidChangeModified: -> new Disposable(->)
|
2013-06-21 02:57:34 +04:00
|
|
|
|
2013-02-18 21:45:02 +04:00
|
|
|
beforeEach ->
|
2014-11-26 01:53:48 +03:00
|
|
|
jasmine.snapshotDeprecations()
|
|
|
|
|
2014-09-30 22:54:50 +04:00
|
|
|
deserializerDisposable = atom.deserializers.add(TestView)
|
2014-10-28 03:15:45 +03:00
|
|
|
container = atom.views.getView(new PaneContainer).__spacePenView
|
2014-09-17 20:09:47 +04:00
|
|
|
containerModel = container.model
|
2013-06-21 02:57:34 +04:00
|
|
|
view1 = new TestView(id: 'view-1', text: 'View 1')
|
|
|
|
view2 = new TestView(id: 'view-2', text: 'View 2')
|
2014-04-24 03:35:51 +04:00
|
|
|
waitsForPromise ->
|
|
|
|
atom.workspace.open('sample.js').then (o) -> editor1 = o
|
|
|
|
|
|
|
|
waitsForPromise ->
|
|
|
|
atom.workspace.open('sample.txt').then (o) -> editor2 = o
|
|
|
|
|
|
|
|
runs ->
|
|
|
|
pane = container.getRoot()
|
2014-09-05 03:41:34 +04:00
|
|
|
paneModel = pane.getModel()
|
2014-04-24 03:35:51 +04:00
|
|
|
paneModel.addItems([view1, editor1, view2, editor2])
|
2013-06-21 02:57:34 +04:00
|
|
|
|
|
|
|
afterEach ->
|
2014-09-30 22:54:50 +04:00
|
|
|
deserializerDisposable.dispose()
|
2014-11-26 01:53:48 +03:00
|
|
|
jasmine.restoreDeprecationsSnapshot()
|
2013-02-18 21:45:02 +04:00
|
|
|
|
2014-01-15 04:00:32 +04:00
|
|
|
describe "when the active pane item changes", ->
|
2014-01-15 22:25:53 +04:00
|
|
|
it "hides all item views except the active one", ->
|
2014-08-27 21:59:53 +04:00
|
|
|
expect(pane.getActiveItem()).toBe view1
|
2014-01-15 04:00:32 +04:00
|
|
|
expect(view1.css('display')).not.toBe 'none'
|
|
|
|
|
2014-01-13 04:40:57 +04:00
|
|
|
pane.activateItem(view2)
|
2013-02-18 22:15:33 +04:00
|
|
|
expect(view1.css('display')).toBe 'none'
|
2013-10-16 20:49:09 +04:00
|
|
|
expect(view2.css('display')).not.toBe 'none'
|
2013-02-18 22:15:33 +04:00
|
|
|
|
2014-01-15 04:00:32 +04:00
|
|
|
it "triggers 'pane:active-item-changed'", ->
|
2013-02-22 03:22:19 +04:00
|
|
|
itemChangedHandler = jasmine.createSpy("itemChangedHandler")
|
|
|
|
container.on 'pane:active-item-changed', itemChangedHandler
|
|
|
|
|
2014-08-27 21:59:53 +04:00
|
|
|
expect(pane.getActiveItem()).toBe view1
|
2014-01-15 04:00:32 +04:00
|
|
|
paneModel.activateItem(view2)
|
|
|
|
paneModel.activateItem(view2)
|
|
|
|
|
2013-02-22 03:22:19 +04:00
|
|
|
expect(itemChangedHandler.callCount).toBe 1
|
|
|
|
expect(itemChangedHandler.argsForCall[0][1]).toBe view2
|
|
|
|
itemChangedHandler.reset()
|
|
|
|
|
2014-01-15 04:00:32 +04:00
|
|
|
paneModel.activateItem(editor1)
|
2013-02-22 03:22:19 +04:00
|
|
|
expect(itemChangedHandler).toHaveBeenCalled()
|
2013-11-20 03:22:47 +04:00
|
|
|
expect(itemChangedHandler.argsForCall[0][1]).toBe editor1
|
2013-02-22 03:22:19 +04:00
|
|
|
itemChangedHandler.reset()
|
|
|
|
|
2014-01-15 04:00:32 +04:00
|
|
|
it "transfers focus to the new active view if the previous view was focused", ->
|
|
|
|
container.attachToDom()
|
|
|
|
pane.focus()
|
|
|
|
expect(pane.activeView).not.toBe view2
|
|
|
|
expect(pane.activeView).toMatchSelector ':focus'
|
|
|
|
paneModel.activateItem(view2)
|
|
|
|
expect(view2).toMatchSelector ':focus'
|
|
|
|
|
|
|
|
describe "when the new activeItem is a model", ->
|
|
|
|
it "shows the item's view or creates and shows a new view for the item if none exists", ->
|
|
|
|
initialViewCount = pane.itemViews.find('.test-view').length
|
|
|
|
|
|
|
|
model1 =
|
|
|
|
id: 'test-model-1'
|
|
|
|
text: 'Test Model 1'
|
|
|
|
serialize: -> {@id, @text}
|
|
|
|
getViewClass: -> TestView
|
|
|
|
|
|
|
|
model2 =
|
|
|
|
id: 'test-model-2'
|
|
|
|
text: 'Test Model 2'
|
|
|
|
serialize: -> {@id, @text}
|
|
|
|
getViewClass: -> TestView
|
|
|
|
|
|
|
|
paneModel.activateItem(model1)
|
|
|
|
paneModel.activateItem(model2)
|
|
|
|
expect(pane.itemViews.find('.test-view').length).toBe initialViewCount + 2
|
|
|
|
|
|
|
|
paneModel.activatePreviousItem()
|
|
|
|
expect(pane.itemViews.find('.test-view').length).toBe initialViewCount + 2
|
|
|
|
|
|
|
|
paneModel.destroyItem(model2)
|
|
|
|
expect(pane.itemViews.find('.test-view').length).toBe initialViewCount + 1
|
|
|
|
|
|
|
|
paneModel.destroyItem(model1)
|
|
|
|
expect(pane.itemViews.find('.test-view').length).toBe initialViewCount
|
|
|
|
|
|
|
|
describe "when the new activeItem is a view", ->
|
2013-02-21 09:28:43 +04:00
|
|
|
it "appends it to the itemViews div if it hasn't already been appended and shows it", ->
|
2013-02-18 22:15:33 +04:00
|
|
|
expect(pane.itemViews.find('#view-2')).not.toExist()
|
2014-01-15 04:00:32 +04:00
|
|
|
paneModel.activateItem(view2)
|
2013-02-18 22:15:33 +04:00
|
|
|
expect(pane.itemViews.find('#view-2')).toExist()
|
2014-01-15 04:00:32 +04:00
|
|
|
paneModel.activateItem(view1)
|
|
|
|
paneModel.activateItem(view2)
|
|
|
|
expect(pane.itemViews.find('#view-2').length).toBe 1
|
2013-02-18 22:44:51 +04:00
|
|
|
|
2014-01-15 04:30:38 +04:00
|
|
|
describe "when an item is destroyed", ->
|
|
|
|
it "triggers the 'pane:item-removed' event with the item and its former index", ->
|
2013-02-26 04:15:00 +04:00
|
|
|
itemRemovedHandler = jasmine.createSpy("itemRemovedHandler")
|
|
|
|
pane.on 'pane:item-removed', itemRemovedHandler
|
2014-01-15 04:30:38 +04:00
|
|
|
paneModel.destroyItem(editor1)
|
2013-02-26 04:15:00 +04:00
|
|
|
expect(itemRemovedHandler).toHaveBeenCalled()
|
2013-11-20 03:22:47 +04:00
|
|
|
expect(itemRemovedHandler.argsForCall[0][1..2]).toEqual [editor1, 1]
|
2013-02-26 04:15:00 +04:00
|
|
|
|
2014-01-15 04:30:38 +04:00
|
|
|
describe "when the destroyed item is a view", ->
|
2013-02-19 02:23:23 +04:00
|
|
|
it "removes the item from the 'item-views' div", ->
|
|
|
|
expect(view1.parent()).toMatchSelector pane.itemViews
|
2014-01-15 04:30:38 +04:00
|
|
|
paneModel.destroyItem(view1)
|
2013-02-19 02:23:23 +04:00
|
|
|
expect(view1.parent()).not.toMatchSelector pane.itemViews
|
|
|
|
|
2014-01-15 04:30:38 +04:00
|
|
|
describe "when the destroyed item is a model", ->
|
|
|
|
it "removes the associated view", ->
|
|
|
|
paneModel.activateItem(editor1)
|
2014-10-09 01:11:57 +04:00
|
|
|
expect(pane.itemViews.find('atom-text-editor').length).toBe 1
|
2014-01-13 04:25:51 +04:00
|
|
|
pane.destroyItem(editor1)
|
2014-10-09 01:11:57 +04:00
|
|
|
expect(pane.itemViews.find('atom-text-editor').length).toBe 0
|
2013-02-19 02:23:23 +04:00
|
|
|
|
2014-01-15 06:15:11 +04:00
|
|
|
describe "when an item is moved within the same pane", ->
|
|
|
|
it "emits a 'pane:item-moved' event with the item and the new index", ->
|
|
|
|
pane.on 'pane:item-moved', itemMovedHandler = jasmine.createSpy("itemMovedHandler")
|
|
|
|
paneModel.moveItem(view1, 2)
|
2013-02-26 06:03:06 +04:00
|
|
|
expect(itemMovedHandler).toHaveBeenCalled()
|
|
|
|
expect(itemMovedHandler.argsForCall[0][1..2]).toEqual [view1, 2]
|
|
|
|
|
2014-01-15 06:26:47 +04:00
|
|
|
describe "when an item is moved to another pane", ->
|
|
|
|
it "detaches the item's view rather than removing it", ->
|
2014-11-11 01:55:00 +03:00
|
|
|
container.attachToDom()
|
|
|
|
expect(view1.is(':visible')).toBe true
|
2014-01-15 06:26:47 +04:00
|
|
|
paneModel2 = paneModel.splitRight()
|
|
|
|
view1.data('preservative', 1234)
|
|
|
|
paneModel.moveItemToPane(view1, paneModel2, 1)
|
|
|
|
expect(view1.data('preservative')).toBe 1234
|
|
|
|
paneModel2.activateItemAtIndex(1)
|
|
|
|
expect(view1.data('preservative')).toBe 1234
|
2014-11-11 01:55:00 +03:00
|
|
|
expect(view1.is(':visible')).toBe true
|
2013-04-09 05:22:58 +04:00
|
|
|
|
2013-03-07 02:12:02 +04:00
|
|
|
describe "when the title of the active item changes", ->
|
2014-11-26 01:35:22 +03:00
|
|
|
describe 'when there is no onDidChangeTitle method (deprecated)', ->
|
2014-09-11 22:28:21 +04:00
|
|
|
beforeEach ->
|
2014-11-26 01:35:22 +03:00
|
|
|
jasmine.snapshotDeprecations()
|
|
|
|
|
2014-09-11 22:28:21 +04:00
|
|
|
view1.onDidChangeTitle = null
|
|
|
|
view2.onDidChangeTitle = null
|
2013-03-07 02:12:02 +04:00
|
|
|
|
2014-09-11 22:28:21 +04:00
|
|
|
pane.activateItem(view2)
|
|
|
|
pane.activateItem(view1)
|
2013-03-07 02:12:02 +04:00
|
|
|
|
2014-11-26 01:35:22 +03:00
|
|
|
afterEach ->
|
|
|
|
jasmine.restoreDeprecationsSnapshot()
|
|
|
|
|
2014-09-11 22:28:21 +04:00
|
|
|
it "emits pane:active-item-title-changed", ->
|
|
|
|
activeItemTitleChangedHandler = jasmine.createSpy("activeItemTitleChangedHandler")
|
|
|
|
pane.on 'pane:active-item-title-changed', activeItemTitleChangedHandler
|
2013-03-07 02:12:02 +04:00
|
|
|
|
2014-09-11 22:28:21 +04:00
|
|
|
expect(pane.getActiveItem()).toBe view1
|
2014-09-11 21:48:03 +04:00
|
|
|
|
2014-09-11 22:28:21 +04:00
|
|
|
view2.trigger 'title-changed'
|
|
|
|
expect(activeItemTitleChangedHandler).not.toHaveBeenCalled()
|
2014-09-11 21:48:03 +04:00
|
|
|
|
2014-09-11 22:28:21 +04:00
|
|
|
view1.trigger 'title-changed'
|
|
|
|
expect(activeItemTitleChangedHandler).toHaveBeenCalled()
|
|
|
|
activeItemTitleChangedHandler.reset()
|
2014-09-11 21:48:03 +04:00
|
|
|
|
|
|
|
pane.activateItem(view2)
|
2014-09-11 22:28:21 +04:00
|
|
|
view2.trigger 'title-changed'
|
|
|
|
expect(activeItemTitleChangedHandler).toHaveBeenCalled()
|
2014-09-11 21:48:03 +04:00
|
|
|
|
2014-09-11 22:28:21 +04:00
|
|
|
describe 'when there is a onDidChangeTitle method', ->
|
2014-09-11 22:11:15 +04:00
|
|
|
it "emits pane:active-item-title-changed", ->
|
2014-09-11 21:48:03 +04:00
|
|
|
activeItemTitleChangedHandler = jasmine.createSpy("activeItemTitleChangedHandler")
|
|
|
|
pane.on 'pane:active-item-title-changed', activeItemTitleChangedHandler
|
|
|
|
|
|
|
|
expect(pane.getActiveItem()).toBe view1
|
|
|
|
view2.changeTitle()
|
|
|
|
expect(activeItemTitleChangedHandler).not.toHaveBeenCalled()
|
|
|
|
|
|
|
|
view1.changeTitle()
|
|
|
|
expect(activeItemTitleChangedHandler).toHaveBeenCalled()
|
|
|
|
activeItemTitleChangedHandler.reset()
|
|
|
|
|
|
|
|
pane.activateItem(view2)
|
|
|
|
view2.changeTitle()
|
|
|
|
expect(activeItemTitleChangedHandler).toHaveBeenCalled()
|
|
|
|
|
2013-12-12 02:48:12 +04:00
|
|
|
describe "when an unmodifed buffer's path is deleted", ->
|
2013-12-11 05:08:07 +04:00
|
|
|
it "removes the pane item", ->
|
2014-04-24 03:35:51 +04:00
|
|
|
editor = null
|
2014-03-18 08:21:19 +04:00
|
|
|
jasmine.unspy(window, 'setTimeout')
|
2014-06-02 21:12:38 +04:00
|
|
|
filePath = path.join(temp.mkdirSync(), 'file.txt')
|
|
|
|
fs.writeFileSync(filePath, '')
|
2013-12-11 05:08:07 +04:00
|
|
|
|
2014-04-24 03:35:51 +04:00
|
|
|
waitsForPromise ->
|
|
|
|
atom.workspace.open(filePath).then (o) -> editor = o
|
|
|
|
|
|
|
|
runs ->
|
|
|
|
pane.activateItem(editor)
|
|
|
|
expect(pane.items).toHaveLength(5)
|
|
|
|
fs.removeSync(filePath)
|
|
|
|
|
|
|
|
waitsFor ->
|
|
|
|
pane.items.length == 4
|
2013-12-11 05:08:07 +04:00
|
|
|
|
2014-01-15 07:10:01 +04:00
|
|
|
describe "when a pane is destroyed", ->
|
2014-01-15 22:25:53 +04:00
|
|
|
[pane2, pane2Model] = []
|
|
|
|
|
|
|
|
beforeEach ->
|
|
|
|
pane2Model = paneModel.splitRight() # Can't destroy the last pane, so we add another
|
2014-12-01 00:47:51 +03:00
|
|
|
pane2 = atom.views.getView(pane2Model).__spacePenView
|
2014-01-15 22:25:53 +04:00
|
|
|
|
2013-02-26 03:26:50 +04:00
|
|
|
it "triggers a 'pane:removed' event with the pane", ->
|
|
|
|
removedHandler = jasmine.createSpy("removedHandler")
|
|
|
|
container.on 'pane:removed', removedHandler
|
2014-01-15 22:25:53 +04:00
|
|
|
paneModel.destroy()
|
2013-02-26 03:26:50 +04:00
|
|
|
expect(removedHandler).toHaveBeenCalled()
|
|
|
|
expect(removedHandler.argsForCall[0][1]).toBe pane
|
|
|
|
|
2014-01-15 07:10:01 +04:00
|
|
|
describe "if the destroyed pane has focus", ->
|
2013-02-22 04:42:51 +04:00
|
|
|
[paneToLeft, paneToRight] = []
|
|
|
|
|
2014-01-15 22:25:53 +04:00
|
|
|
it "focuses the next pane", ->
|
|
|
|
container.attachToDom()
|
2014-06-09 12:09:02 +04:00
|
|
|
pane2.activate()
|
2014-01-15 22:25:53 +04:00
|
|
|
expect(pane.hasFocus()).toBe false
|
|
|
|
expect(pane2.hasFocus()).toBe true
|
|
|
|
pane2Model.destroy()
|
|
|
|
expect(pane.hasFocus()).toBe true
|
2013-02-22 04:42:51 +04:00
|
|
|
|
2013-12-13 22:28:38 +04:00
|
|
|
describe "::getNextPane()", ->
|
2013-03-08 00:21:20 +04:00
|
|
|
it "returns the next pane if one exists, wrapping around from the last pane to the first", ->
|
2014-01-13 04:40:57 +04:00
|
|
|
pane.activateItem(editor1)
|
2013-03-08 00:21:20 +04:00
|
|
|
expect(pane.getNextPane()).toBeUndefined
|
2013-10-30 22:01:43 +04:00
|
|
|
pane2 = pane.splitRight(pane.copyActiveItem())
|
2013-03-08 00:21:20 +04:00
|
|
|
expect(pane.getNextPane()).toBe pane2
|
|
|
|
expect(pane2.getNextPane()).toBe pane
|
|
|
|
|
2014-01-15 07:27:30 +04:00
|
|
|
describe "when the pane's active status changes", ->
|
|
|
|
[pane2, pane2Model] = []
|
|
|
|
|
|
|
|
beforeEach ->
|
|
|
|
pane2Model = paneModel.splitRight(items: [pane.copyActiveItem()])
|
2014-12-01 00:47:51 +03:00
|
|
|
pane2 = atom.views.getView(pane2Model).__spacePenView
|
2014-01-15 07:27:30 +04:00
|
|
|
expect(pane2Model.isActive()).toBe true
|
|
|
|
|
|
|
|
it "adds or removes the .active class as appropriate", ->
|
|
|
|
expect(pane).not.toHaveClass('active')
|
|
|
|
paneModel.activate()
|
|
|
|
expect(pane).toHaveClass('active')
|
|
|
|
pane2Model.activate()
|
|
|
|
expect(pane).not.toHaveClass('active')
|
|
|
|
|
|
|
|
it "triggers 'pane:became-active' or 'pane:became-inactive' according to the current status", ->
|
|
|
|
pane.on 'pane:became-active', becameActiveHandler = jasmine.createSpy("becameActiveHandler")
|
|
|
|
pane.on 'pane:became-inactive', becameInactiveHandler = jasmine.createSpy("becameInactiveHandler")
|
|
|
|
paneModel.activate()
|
|
|
|
|
|
|
|
expect(becameActiveHandler.callCount).toBe 1
|
|
|
|
expect(becameInactiveHandler.callCount).toBe 0
|
|
|
|
|
|
|
|
pane2Model.activate()
|
|
|
|
expect(becameActiveHandler.callCount).toBe 1
|
|
|
|
expect(becameInactiveHandler.callCount).toBe 1
|
|
|
|
|
2013-02-21 07:55:38 +04:00
|
|
|
describe "when the pane is focused", ->
|
2013-10-16 20:49:19 +04:00
|
|
|
beforeEach ->
|
|
|
|
container.attachToDom()
|
|
|
|
|
2014-01-15 07:27:30 +04:00
|
|
|
it "transfers focus to the active view", ->
|
2013-02-21 03:42:16 +04:00
|
|
|
focusHandler = jasmine.createSpy("focusHandler")
|
2014-08-27 21:59:53 +04:00
|
|
|
pane.getActiveItem().on 'focus', focusHandler
|
2013-02-21 03:42:16 +04:00
|
|
|
pane.focus()
|
|
|
|
expect(focusHandler).toHaveBeenCalled()
|
|
|
|
|
2014-01-15 07:27:30 +04:00
|
|
|
it "makes the pane active", ->
|
|
|
|
paneModel.splitRight(items: [pane.copyActiveItem()])
|
|
|
|
expect(paneModel.isActive()).toBe false
|
|
|
|
pane.focus()
|
|
|
|
expect(paneModel.isActive()).toBe true
|
2013-08-16 04:28:14 +04:00
|
|
|
|
2014-01-15 07:16:28 +04:00
|
|
|
describe "when a pane is split", ->
|
2014-10-08 22:32:58 +04:00
|
|
|
it "builds the appropriateatom-pane-axis.horizontal and pane-column views", ->
|
2013-02-21 09:28:43 +04:00
|
|
|
pane1 = pane
|
2014-09-05 03:41:34 +04:00
|
|
|
pane1Model = pane.getModel()
|
2014-01-13 04:40:57 +04:00
|
|
|
pane.activateItem(editor1)
|
2014-01-15 07:16:28 +04:00
|
|
|
|
|
|
|
pane2Model = pane1Model.splitRight(items: [pane1Model.copyActiveItem()])
|
|
|
|
pane3Model = pane2Model.splitDown(items: [pane2Model.copyActiveItem()])
|
|
|
|
pane2 = pane2Model._view
|
2014-12-01 00:47:51 +03:00
|
|
|
pane2 = atom.views.getView(pane2Model).__spacePenView
|
|
|
|
pane3 = atom.views.getView(pane3Model).__spacePenView
|
2014-01-15 07:16:28 +04:00
|
|
|
|
2014-10-08 22:32:58 +04:00
|
|
|
expect(container.find('> atom-pane-axis.horizontal > atom-pane').toArray()).toEqual [pane1[0]]
|
|
|
|
expect(container.find('> atom-pane-axis.horizontal > atom-pane-axis.vertical > atom-pane').toArray()).toEqual [pane2[0], pane3[0]]
|
2014-01-15 07:16:28 +04:00
|
|
|
|
|
|
|
pane1Model.destroy()
|
2014-10-08 22:32:58 +04:00
|
|
|
expect(container.find('> atom-pane-axis.vertical > atom-pane').toArray()).toEqual [pane2[0], pane3[0]]
|
2013-02-21 07:53:34 +04:00
|
|
|
|
2013-02-21 03:01:08 +04:00
|
|
|
describe "serialization", ->
|
2013-03-07 04:05:26 +04:00
|
|
|
it "focuses the pane after attach only if had focus when serialized", ->
|
2013-07-22 02:55:44 +04:00
|
|
|
container.attachToDom()
|
2013-03-07 04:05:26 +04:00
|
|
|
pane.focus()
|
2013-12-07 14:25:47 +04:00
|
|
|
|
2014-10-28 03:15:45 +03:00
|
|
|
container2 = atom.views.getView(container.model.testSerialization()).__spacePenView
|
2013-12-07 14:25:47 +04:00
|
|
|
pane2 = container2.getRoot()
|
|
|
|
container2.attachToDom()
|
|
|
|
expect(pane2).toMatchSelector(':has(:focus)')
|
2013-03-07 04:05:26 +04:00
|
|
|
|
|
|
|
$(document.activeElement).blur()
|
2014-10-28 03:15:45 +03:00
|
|
|
container3 = atom.views.getView(container.model.testSerialization()).__spacePenView
|
2013-12-07 14:25:47 +04:00
|
|
|
pane3 = container3.getRoot()
|
|
|
|
container3.attachToDom()
|
|
|
|
expect(pane3).not.toMatchSelector(':has(:focus)')
|