]> git.r.bdr.sh - rbdr/dotfiles/blob - atom/packages/ex-mode/spec/ex-mode-spec.coffee
bbc7fd7107d6f119b2bba9f3360bae49e7f2e4c9
[rbdr/dotfiles] / atom / packages / ex-mode / spec / ex-mode-spec.coffee
1 ExMode = require '../lib/ex-mode'
2
3 # Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
4 #
5 # To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit`
6 # or `fdescribe`). Remove the `f` to unfocus the block.
7
8 describe "ExMode", ->
9 [workspaceElement, activationPromise] = []
10
11 beforeEach ->
12 workspaceElement = atom.views.getView(atom.workspace)
13 activationPromise = atom.packages.activatePackage('ex-mode')
14
15 describe "when the ex-mode:toggle event is triggered", ->
16 it "hides and shows the modal panel", ->
17 # Before the activation event the view is not on the DOM, and no panel
18 # has been created
19 expect(workspaceElement.querySelector('.ex-mode')).not.toExist()
20
21 # This is an activation event, triggering it will cause the package to be
22 # activated.
23 atom.commands.dispatch workspaceElement, 'ex-mode:toggle'
24
25 waitsForPromise ->
26 activationPromise
27
28 runs ->
29 expect(workspaceElement.querySelector('.ex-mode')).toExist()
30
31 exModeElement = workspaceElement.querySelector('.ex-mode')
32 expect(exModeElement).toExist()
33
34 exModePanel = atom.workspace.panelForItem(exModeElement)
35 expect(exModePanel.isVisible()).toBe true
36 atom.commands.dispatch workspaceElement, 'ex-mode:toggle'
37 expect(exModePanel.isVisible()).toBe false
38
39 it "hides and shows the view", ->
40 # This test shows you an integration test testing at the view level.
41
42 # Attaching the workspaceElement to the DOM is required to allow the
43 # `toBeVisible()` matchers to work. Anything testing visibility or focus
44 # requires that the workspaceElement is on the DOM. Tests that attach the
45 # workspaceElement to the DOM are generally slower than those off DOM.
46 jasmine.attachToDOM(workspaceElement)
47
48 expect(workspaceElement.querySelector('.ex-mode')).not.toExist()
49
50 # This is an activation event, triggering it causes the package to be
51 # activated.
52 atom.commands.dispatch workspaceElement, 'ex-mode:toggle'
53
54 waitsForPromise ->
55 activationPromise
56
57 runs ->
58 # Now we can test for view visibility
59 exModeElement = workspaceElement.querySelector('.ex-mode')
60 expect(exModeElement).toBeVisible()
61 atom.commands.dispatch workspaceElement, 'ex-mode:toggle'
62 expect(exModeElement).not.toBeVisible()