"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/templates/package-javascript/spec/__package-name__-spec.js.template" (8 Mar 2017, 2825 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 'use babel';
    2 
    3 import __PackageName__ from '../lib/__package-name__';
    4 
    5 // Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
    6 //
    7 // To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit`
    8 // or `fdescribe`). Remove the `f` to unfocus the block.
    9 
   10 describe('__PackageName__', () => {
   11   let workspaceElement, activationPromise;
   12 
   13   beforeEach(() => {
   14     workspaceElement = atom.views.getView(atom.workspace);
   15     activationPromise = atom.packages.activatePackage('__package-name__');
   16   });
   17 
   18   describe('when the __package-name__:toggle event is triggered', () => {
   19     it('hides and shows the modal panel', () => {
   20       // Before the activation event the view is not on the DOM, and no panel
   21       // has been created
   22       expect(workspaceElement.querySelector('.__package-name__')).not.toExist();
   23 
   24       // This is an activation event, triggering it will cause the package to be
   25       // activated.
   26       atom.commands.dispatch(workspaceElement, '__package-name__:toggle');
   27 
   28       waitsForPromise(() => {
   29         return activationPromise;
   30       });
   31 
   32       runs(() => {
   33         expect(workspaceElement.querySelector('.__package-name__')).toExist();
   34 
   35         let __packageName__Element = workspaceElement.querySelector('.__package-name__');
   36         expect(__packageName__Element).toExist();
   37 
   38         let __packageName__Panel = atom.workspace.panelForItem(__packageName__Element);
   39         expect(__packageName__Panel.isVisible()).toBe(true);
   40         atom.commands.dispatch(workspaceElement, '__package-name__:toggle');
   41         expect(__packageName__Panel.isVisible()).toBe(false);
   42       });
   43     });
   44 
   45     it('hides and shows the view', () => {
   46       // This test shows you an integration test testing at the view level.
   47 
   48       // Attaching the workspaceElement to the DOM is required to allow the
   49       // `toBeVisible()` matchers to work. Anything testing visibility or focus
   50       // requires that the workspaceElement is on the DOM. Tests that attach the
   51       // workspaceElement to the DOM are generally slower than those off DOM.
   52       jasmine.attachToDOM(workspaceElement);
   53 
   54       expect(workspaceElement.querySelector('.__package-name__')).not.toExist();
   55 
   56       // This is an activation event, triggering it causes the package to be
   57       // activated.
   58       atom.commands.dispatch(workspaceElement, '__package-name__:toggle');
   59 
   60       waitsForPromise(() => {
   61         return activationPromise;
   62       });
   63 
   64       runs(() => {
   65         // Now we can test for view visibility
   66         let __packageName__Element = workspaceElement.querySelector('.__package-name__');
   67         expect(__packageName__Element).toBeVisible();
   68         atom.commands.dispatch(workspaceElement, '__package-name__:toggle');
   69         expect(__packageName__Element).not.toBeVisible();
   70       });
   71     });
   72   });
   73 });