Project drawer state is restored upon refresh

This commit is contained in:
Corey Johnson & Nathan Sobo
2012-05-02 16:08:02 -07:00
parent 5864fa5145
commit bb689574d0
3 changed files with 52 additions and 8 deletions

View File

@@ -9,7 +9,9 @@ describe "TreeView", ->
beforeEach ->
rootView = new RootView(pathToOpen: require.resolve('fixtures/'))
project = rootView.project
treeView = new TreeView(rootView)
rootView.registerExtension(TreeView)
treeView = rootView.find(".tree-view").view()
treeView.root = treeView.find('> li:first').view()
sampleJs = treeView.find('.file:contains(sample.js)')
sampleTxt = treeView.find('.file:contains(sample.txt)')
@@ -38,6 +40,24 @@ describe "TreeView", ->
expect(rootEntries.find('> .file:contains(sample.js)')).toExist()
expect(rootEntries.find('> .file:contains(sample.txt)')).toExist()
describe "serialization", ->
newTreeView = null
afterEach ->
newTreeView.deactivate()
it "restores expanded directories and selected file when deserialized", ->
treeView.find('.directory:contains(zed)').click()
sampleJs.click()
newRootView = RootView.deserialize(rootView.serialize())
newRootView.registerExtension(TreeView)
newTreeView = newRootView.find(".tree-view").view()
expect(newTreeView).toExist()
expect(newTreeView.selectedEntry()).toMatchSelector(".file:contains(sample.js)")
expect(newTreeView.find(".directory:contains(zed)")).toHaveClass("expanded")
describe "when a directory's disclosure arrow is clicked", ->
it "expands / collapses the associated directory", ->
subdir = treeView.root.find('.entries > li:contains(dir/)').view()