1 ExMode = require '../lib/ex-mode'
3 # Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
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.
9 [workspaceElement, activationPromise] = []
12 workspaceElement = atom.views.getView(atom.workspace)
13 activationPromise = atom.packages.activatePackage('ex-mode')
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
19 expect(workspaceElement.querySelector('.ex-mode')).not.toExist()
21 # This is an activation event, triggering it will cause the package to be
23 atom.commands.dispatch workspaceElement, 'ex-mode:toggle'
29 expect(workspaceElement.querySelector('.ex-mode')).toExist()
31 exModeElement = workspaceElement.querySelector('.ex-mode')
32 expect(exModeElement).toExist()
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
39 it "hides and shows the view", ->
40 # This test shows you an integration test testing at the view level.
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)
48 expect(workspaceElement.querySelector('.ex-mode')).not.toExist()
50 # This is an activation event, triggering it causes the package to be
52 atom.commands.dispatch workspaceElement, 'ex-mode:toggle'
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()