You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.7 KiB
JavaScript
74 lines
2.7 KiB
JavaScript
|
8 years ago
|
'use babel';
|
||
|
|
|
||
|
|
import LatexHelper from '../lib/latex-helper';
|
||
|
|
|
||
|
|
// Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
|
||
|
|
//
|
||
|
|
// To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit`
|
||
|
|
// or `fdescribe`). Remove the `f` to unfocus the block.
|
||
|
|
|
||
|
|
describe('LatexHelper', () => {
|
||
|
|
let workspaceElement, activationPromise;
|
||
|
|
|
||
|
|
beforeEach(() => {
|
||
|
|
workspaceElement = atom.views.getView(atom.workspace);
|
||
|
|
activationPromise = atom.packages.activatePackage('latex-helper');
|
||
|
|
});
|
||
|
|
|
||
|
|
describe('when the latex-helper:toggle event is triggered', () => {
|
||
|
|
it('hides and shows the modal panel', () => {
|
||
|
|
// Before the activation event the view is not on the DOM, and no panel
|
||
|
|
// has been created
|
||
|
|
expect(workspaceElement.querySelector('.latex-helper')).not.toExist();
|
||
|
|
|
||
|
|
// This is an activation event, triggering it will cause the package to be
|
||
|
|
// activated.
|
||
|
|
atom.commands.dispatch(workspaceElement, 'latex-helper:toggle');
|
||
|
|
|
||
|
|
waitsForPromise(() => {
|
||
|
|
return activationPromise;
|
||
|
|
});
|
||
|
|
|
||
|
|
runs(() => {
|
||
|
|
expect(workspaceElement.querySelector('.latex-helper')).toExist();
|
||
|
|
|
||
|
|
let latexHelperElement = workspaceElement.querySelector('.latex-helper');
|
||
|
|
expect(latexHelperElement).toExist();
|
||
|
|
|
||
|
|
let latexHelperPanel = atom.workspace.panelForItem(latexHelperElement);
|
||
|
|
expect(latexHelperPanel.isVisible()).toBe(true);
|
||
|
|
atom.commands.dispatch(workspaceElement, 'latex-helper:toggle');
|
||
|
|
expect(latexHelperPanel.isVisible()).toBe(false);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
it('hides and shows the view', () => {
|
||
|
|
// This test shows you an integration test testing at the view level.
|
||
|
|
|
||
|
|
// Attaching the workspaceElement to the DOM is required to allow the
|
||
|
|
// `toBeVisible()` matchers to work. Anything testing visibility or focus
|
||
|
|
// requires that the workspaceElement is on the DOM. Tests that attach the
|
||
|
|
// workspaceElement to the DOM are generally slower than those off DOM.
|
||
|
|
jasmine.attachToDOM(workspaceElement);
|
||
|
|
|
||
|
|
expect(workspaceElement.querySelector('.latex-helper')).not.toExist();
|
||
|
|
|
||
|
|
// This is an activation event, triggering it causes the package to be
|
||
|
|
// activated.
|
||
|
|
atom.commands.dispatch(workspaceElement, 'latex-helper:toggle');
|
||
|
|
|
||
|
|
waitsForPromise(() => {
|
||
|
|
return activationPromise;
|
||
|
|
});
|
||
|
|
|
||
|
|
runs(() => {
|
||
|
|
// Now we can test for view visibility
|
||
|
|
let latexHelperElement = workspaceElement.querySelector('.latex-helper');
|
||
|
|
expect(latexHelperElement).toBeVisible();
|
||
|
|
atom.commands.dispatch(workspaceElement, 'latex-helper:toggle');
|
||
|
|
expect(latexHelperElement).not.toBeVisible();
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|