2013-11-22 04:53:38 +04:00
|
|
|
{View, $, $$} = require 'atom'
|
2012-12-14 23:08:18 +04:00
|
|
|
|
|
|
|
describe "SpacePen extensions", ->
|
|
|
|
class TestView extends View
|
|
|
|
@content: -> @div()
|
|
|
|
|
2012-12-15 02:40:51 +04:00
|
|
|
[view, parent] = []
|
2012-12-14 23:08:18 +04:00
|
|
|
|
|
|
|
beforeEach ->
|
|
|
|
view = new TestView
|
|
|
|
parent = $$ -> @div()
|
|
|
|
parent.append(view)
|
|
|
|
|
2012-12-20 04:28:38 +04:00
|
|
|
describe "View.subscribe(eventEmitter, eventName, callback)", ->
|
2012-12-15 02:40:51 +04:00
|
|
|
[emitter, eventHandler] = []
|
|
|
|
|
|
|
|
beforeEach ->
|
|
|
|
eventHandler = jasmine.createSpy 'eventHandler'
|
|
|
|
emitter = $$ -> @div()
|
|
|
|
view.subscribe emitter, 'foo', eventHandler
|
|
|
|
|
|
|
|
it "subscribes to the given event emitter and unsubscribes when unsubscribe is called", ->
|
|
|
|
emitter.trigger "foo"
|
|
|
|
expect(eventHandler).toHaveBeenCalled()
|
2013-11-22 04:53:38 +04:00
|
|
|
|
|
|
|
describe "tooltips", ->
|
2014-01-22 00:33:23 +04:00
|
|
|
describe "when the window is resized", ->
|
|
|
|
it "hides the tooltips", ->
|
|
|
|
class TooltipView extends View
|
|
|
|
@content: ->
|
|
|
|
@div()
|
|
|
|
|
|
|
|
view = new TooltipView()
|
|
|
|
view.attachToDom()
|
|
|
|
view.setTooltip('this is a tip')
|
|
|
|
|
|
|
|
view.tooltip('show')
|
|
|
|
expect($(document.body).find('.tooltip')).toBeVisible()
|
|
|
|
|
|
|
|
$(window).trigger('resize')
|
|
|
|
expect($(document.body).find('.tooltip')).not.toExist()
|