forked from santip/resize-panes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresize-pane-view-spec.coffee
137 lines (100 loc) · 5.46 KB
/
resize-pane-view-spec.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
{$, View} = require 'atom-space-pen-views'
_ = require 'underscore-plus'
path = require 'path'
ResizePaneView = require '../lib/resize-pane-view'
ResizePane = require '../lib/main'
describe "Resize Pane", ->
workspaceElement = null
beforeEach ->
workspaceElement = atom.views.getView(atom.workspace)
describe ".activate()", ->
beforeEach ->
jasmine.attachToDOM(workspaceElement)
waitsForPromise ->
atom.packages.activatePackage('resize-panes')
it "does not add resize panel for single panes", ->
expect(workspaceElement.querySelectorAll('.pane').length).toBe 1
expect(workspaceElement.querySelectorAll('.pane > .resize-pane-handle.horizontal').length).toBe 0
describe "Load with Existing Panels", ->
beforeEach ->
workspaceElement = atom.views.getView(atom.workspace)
pane1 = atom.workspace.getActivePane()
pane2 = pane1.splitRight()
pane2.activate()
jasmine.attachToDOM(workspaceElement)
waitsForPromise ->
atom.packages.activatePackage('resize-panes')
it "should add a resize pane to the first editor when there are two horizontal panes", ->
expect(workspaceElement.querySelectorAll('.pane').length).toBe 2
expect(workspaceElement.querySelectorAll('.resize-pane-handle.horizontal').length).toBe 1
describe "Pane Split Scenarios", ->
beforeEach ->
jasmine.attachToDOM(workspaceElement)
waitsForPromise ->
atom.packages.activatePackage('resize-panes')
describe "Horizontal Split Panes", ->
it "should add one resize pane when there are two panes", ->
pane1 = atom.workspace.getActivePane()
pane2 = pane1.splitRight()
pane2.activate()
jasmine.attachToDOM(workspaceElement)
expect(workspaceElement.querySelectorAll('.pane').length).toBe 2
expect(workspaceElement.querySelectorAll('.resize-pane-handle.horizontal').length).toBe 1
it "should add two resize panes when there are three horizontal panes", ->
pane1 = atom.workspace.getActivePane()
pane2 = pane1.splitRight()
pane2.activate()
jasmine.attachToDOM(workspaceElement)
expect(workspaceElement.querySelectorAll('.pane').length).toBe 2
expect(workspaceElement.querySelectorAll('.resize-pane-handle.horizontal').length).toBe 1
pane3 = pane2.splitRight()
pane3.activate()
jasmine.attachToDOM(workspaceElement)
expect(workspaceElement.querySelectorAll('.pane').length).toBe 3
expect(workspaceElement.querySelectorAll('.resize-pane-handle.horizontal').length).toBe 2
describe "Horizontal Split With Virtual Split Panes", ->
it "should add a one resize pane when there are two h panes with one split v", ->
pane1 = atom.workspace.getActivePane()
pane2 = pane1.splitRight()
pane2.activate()
jasmine.attachToDOM(workspaceElement)
expect(workspaceElement.querySelectorAll('.pane').length).toBe 2
expect(workspaceElement.querySelectorAll('.resize-pane-handle.horizontal').length).toBe 1
pane3 = pane2.splitDown()
pane3.activate()
jasmine.attachToDOM(workspaceElement)
expect(workspaceElement.querySelectorAll('.pane').length).toBe 3
expect(workspaceElement.querySelectorAll('.resize-pane-handle.horizontal').length).toBe 1
it "should add a two resize pane when there are three h panes with one split v", ->
pane1 = atom.workspace.getActivePane()
pane2 = pane1.splitRight()
pane3 = pane2.splitRight()
pane4 = pane2.splitDown()
jasmine.attachToDOM(workspaceElement)
expect(workspaceElement.querySelectorAll('.pane').length).toBe 4
expect(workspaceElement.querySelectorAll('.resize-pane-handle.horizontal').length).toBe 2
expect(workspaceElement.querySelectorAll('.pane')[0].nextSibling.getAttribute('class')).toBe "resize-pane-handle horizontal"
expect(workspaceElement.querySelectorAll('.pane')[0].nextSibling.nextSibling.getAttribute('class')).toBe "vertical pane-column"
describe "Horizontal Split With Virtual Split Panes When Closing", ->
it "should add two resize panes when there are two h panes with one split v after closing the bottom vertical pane", ->
pane1 = atom.workspace.getActivePane()
pane2 = pane1.splitRight()
pane2.activate()
pane3 = pane2.splitDown()
pane3.activate()
jasmine.attachToDOM(workspaceElement)
expect(workspaceElement.querySelectorAll('.pane').length).toBe 3
expect(workspaceElement.querySelectorAll('.resize-pane-handle.horizontal').length).toBe 1
pane3.close()
jasmine.attachToDOM(workspaceElement)
expect(workspaceElement.querySelectorAll('.pane').length).toBe 2
expect(workspaceElement.querySelectorAll('.resize-pane-handle.horizontal').length).toBe 1
expect(workspaceElement.querySelectorAll('.pane')[0].nextSibling.getAttribute('class')).toBe "resize-pane-handle horizontal"
describe "Vertical Split Panes", ->
it "should add a resize pane when it splits vertically", ->
pane1 = atom.workspace.getActivePane()
pane2 = pane1.splitDown()
pane2.activate()
expect(workspaceElement.querySelectorAll('.pane').length).toBe 2
expect(workspaceElement.querySelectorAll('.resize-pane-handle.vertical').length).toBe 1
expect(workspaceElement.querySelectorAll('.pane')[0].nextSibling.getAttribute('class')).toBe "resize-pane-handle vertical"