"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/templates/package-coffeescript/spec/__package-name__-spec.coffee.template" (8 Mar 2017, 2625 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 __PackageName__ = require '../lib/__package-name__'
    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 "__PackageName__", ->
    9   [workspaceElement, activationPromise] = []
   10 
   11   beforeEach ->
   12     workspaceElement = atom.views.getView(atom.workspace)
   13     activationPromise = atom.packages.activatePackage('__package-name__')
   14 
   15   describe "when the __package-name__: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('.__package-name__')).not.toExist()
   20 
   21       # This is an activation event, triggering it will cause the package to be
   22       # activated.
   23       atom.commands.dispatch workspaceElement, '__package-name__:toggle'
   24 
   25       waitsForPromise ->
   26         activationPromise
   27 
   28       runs ->
   29         expect(workspaceElement.querySelector('.__package-name__')).toExist()
   30 
   31         __packageName__Element = workspaceElement.querySelector('.__package-name__')
   32         expect(__packageName__Element).toExist()
   33 
   34         __packageName__Panel = atom.workspace.panelForItem(__packageName__Element)
   35         expect(__packageName__Panel.isVisible()).toBe true
   36         atom.commands.dispatch workspaceElement, '__package-name__:toggle'
   37         expect(__packageName__Panel.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('.__package-name__')).not.toExist()
   49 
   50       # This is an activation event, triggering it causes the package to be
   51       # activated.
   52       atom.commands.dispatch workspaceElement, '__package-name__:toggle'
   53 
   54       waitsForPromise ->
   55         activationPromise
   56 
   57       runs ->
   58         # Now we can test for view visibility
   59         __packageName__Element = workspaceElement.querySelector('.__package-name__')
   60         expect(__packageName__Element).toBeVisible()
   61         atom.commands.dispatch workspaceElement, '__package-name__:toggle'
   62         expect(__packageName__Element).not.toBeVisible()