1 | 'use babel'; |
||
2 | |||
3 | import DevmindBeautifier from '../lib/devmind-beautifier'; |
||
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('DevmindBeautifier', () => { |
||
11 | let workspaceElement, activationPromise; |
||
12 | |||
13 | beforeEach(() => { |
||
14 | workspaceElement = atom.views.getView(atom.workspace); |
||
0 ignored issues
–
show
|
|||
15 | activationPromise = atom.packages.activatePackage('devmind-beautifier'); |
||
16 | }); |
||
17 | |||
18 | describe('when the devmind-beautifier: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('.devmind-beautifier')).not.toExist(); |
||
23 | |||
24 | // This is an activation event, triggering it will cause the package to be |
||
25 | // activated. |
||
26 | atom.commands.dispatch(workspaceElement, 'devmind-beautifier:toggle'); |
||
0 ignored issues
–
show
The variable
atom seems to be never declared. If this is a global, consider adding a /** global: atom */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN.
Loading history...
|
|||
27 | |||
28 | waitsForPromise(() => { |
||
29 | return activationPromise; |
||
30 | }); |
||
31 | |||
32 | runs(() => { |
||
33 | expect(workspaceElement.querySelector('.devmind-beautifier')).toExist(); |
||
34 | |||
35 | let devmindBeautifierElement = workspaceElement.querySelector('.devmind-beautifier'); |
||
36 | expect(devmindBeautifierElement).toExist(); |
||
37 | |||
38 | let devmindBeautifierPanel = atom.workspace.panelForItem(devmindBeautifierElement); |
||
0 ignored issues
–
show
The variable
atom seems to be never declared. If this is a global, consider adding a /** global: atom */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN.
Loading history...
|
|||
39 | expect(devmindBeautifierPanel.isVisible()).toBe(true); |
||
40 | atom.commands.dispatch(workspaceElement, 'devmind-beautifier:toggle'); |
||
41 | expect(devmindBeautifierPanel.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); |
||
0 ignored issues
–
show
The variable
jasmine seems to be never declared. If this is a global, consider adding a /** global: jasmine */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN.
Loading history...
|
|||
53 | |||
54 | expect(workspaceElement.querySelector('.devmind-beautifier')).not.toExist(); |
||
55 | |||
56 | // This is an activation event, triggering it causes the package to be |
||
57 | // activated. |
||
58 | atom.commands.dispatch(workspaceElement, 'devmind-beautifier:toggle'); |
||
0 ignored issues
–
show
The variable
atom seems to be never declared. If this is a global, consider adding a /** global: atom */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN.
Loading history...
|
|||
59 | |||
60 | waitsForPromise(() => { |
||
61 | return activationPromise; |
||
62 | }); |
||
63 | |||
64 | runs(() => { |
||
65 | // Now we can test for view visibility |
||
66 | let devmindBeautifierElement = workspaceElement.querySelector('.devmind-beautifier'); |
||
67 | expect(devmindBeautifierElement).toBeVisible(); |
||
68 | atom.commands.dispatch(workspaceElement, 'devmind-beautifier:toggle'); |
||
0 ignored issues
–
show
The variable
atom seems to be never declared. If this is a global, consider adding a /** global: atom */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN.
Loading history...
|
|||
69 | expect(devmindBeautifierElement).not.toBeVisible(); |
||
70 | }); |
||
71 | }); |
||
72 | }); |
||
73 | }); |
||
74 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.