-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpanel-element-spec.coffee
63 lines (47 loc) · 2.11 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
57
58
59
60
61
62
63
Panel = require '../src/panel'
PanelElement = require '../src/panel-element'
describe "PanelElement", ->
[jasmineContent, element, panel] = []
class TestPanelItem
constructior: ->
class TestPanelItemElement extends HTMLElement
createdCallback: ->
@classList.add('test-root')
initialize: (@model) ->
this
TestPanelItemElement = document.registerElement 'atom-test-item-element', prototype: TestPanelItemElement.prototype
beforeEach ->
jasmineContent = document.body.querySelector('#jasmine-content')
atom.views.addViewProvider Panel, (model) ->
new PanelElement().initialize(model)
atom.views.addViewProvider TestPanelItem, (model) ->
new TestPanelItemElement().initialize(model)
it 'removes the element when the panel is destroyed', ->
panel = new Panel({item: new TestPanelItem})
element = atom.views.getView(panel)
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({visible: false, item: new TestPanelItem})
element = atom.views.getView(panel)
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({item: new TestPanelItem})
element = atom.views.getView(panel)
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'
describe "when a class name is specified", ->
it 'initially renders panel created with visibile: false', ->
panel = new Panel({className: 'some classes', item: new TestPanelItem})
element = atom.views.getView(panel)
jasmineContent.appendChild(element)
expect(element).toHaveClass 'some'
expect(element).toHaveClass 'classes'