-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpanel-element-spec.coffee
56 lines (43 loc) · 1.86 KB
/
panel-element-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
ViewRegistry = require '../src/view-registry'
Panel = require '../src/panel'
PanelElement = require '../src/panel-element'
describe "PanelElement", ->
[jasmineContent, element, panel, viewRegistry] = []
class TestPanelItem
constructior: ->
class TestPanelItemElement extends HTMLElement
createdCallback: ->
@classList.add('test-root')
setModel: (@model) ->
TestPanelItemElement = document.registerElement 'atom-test-item-element', prototype: TestPanelItemElement.prototype
beforeEach ->
jasmineContent = document.body.querySelector('#jasmine-content')
viewRegistry = new ViewRegistry
viewRegistry.addViewProvider
modelConstructor: Panel
viewConstructor: PanelElement
viewRegistry.addViewProvider
modelConstructor: TestPanelItem
viewConstructor: TestPanelItemElement
it 'removes the element when the panel is destroyed', ->
panel = new Panel({viewRegistry, item: new TestPanelItem})
element = panel.getView()
jasmineContent.appendChild(element)
expect(element.parentNode).toBe jasmineContent
panel.destroy()
expect(element.parentNode).not.toBe jasmineContent
describe "changing panel visibility", ->
it 'initially renders panel created with visibile: false', ->
panel = new Panel({viewRegistry, visible: false, item: new TestPanelItem})
element = panel.getView()
jasmineContent.appendChild(element)
expect(element.style.display).toBe 'none'
it 'hides and shows the panel element when Panel::hide() and Panel::show() are called', ->
panel = new Panel({viewRegistry, item: new TestPanelItem})
element = panel.getView()
jasmineContent.appendChild(element)
expect(element.style.display).not.toBe 'none'
panel.hide()
expect(element.style.display).toBe 'none'
panel.show()
expect(element.style.display).not.toBe 'none'