-
Notifications
You must be signed in to change notification settings - Fork 0
/
space-pen-extensions-spec.coffee
54 lines (41 loc) · 1.72 KB
/
space-pen-extensions-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
{View, $, $$} = require 'atom'
describe "SpacePen extensions", ->
class TestView extends View
@content: -> @div()
[view, parent] = []
beforeEach ->
view = new TestView
parent = $$ -> @div()
parent.append(view)
describe "View.subscribe(eventEmitter, eventName, callback)", ->
[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()
describe "tooltips", ->
describe "humanizeKeystrokes", ->
humanizeKeystrokes = $.fn.setTooltip.humanizeKeystrokes
it "replaces single keystroke", ->
expect(humanizeKeystrokes('cmd-O')).toEqual '⌘⇧O'
expect(humanizeKeystrokes('cmd-shift-up')).toEqual '⌘⇧↑'
expect(humanizeKeystrokes('cmd-option-down')).toEqual '⌘⌥↓'
expect(humanizeKeystrokes('cmd-option-left')).toEqual '⌘⌥←'
expect(humanizeKeystrokes('cmd-option-right')).toEqual '⌘⌥→'
it "replaces multiple keystroke", ->
expect(humanizeKeystrokes('cmd-o ctrl-2')).toEqual '⌘O ⌃2'
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()