@@ -11,27 +11,45 @@ describe "Minimap Plugins", ->
1111 atom .workspaceView .attachToDom ()
1212 editorView = atom .workspaceView .getActiveView ()
1313
14+ atom .config .set ' minimap.plugins.dummy' , undefined
15+
1416 @plugin =
15- activatePlugin : ->
16- deactivatePlugin : ->
17+ active : false
18+ activatePlugin : -> @active = true
19+ deactivatePlugin : -> @active = false
20+ isActive : -> @active
21+
22+ spyOn (@plugin , ' activatePlugin' ).andCallThrough ()
23+ spyOn (@plugin , ' deactivatePlugin' ).andCallThrough ()
1724
18- spyOn @plugin , ' activatePlugin '
19- spyOn @plugin , ' deactivatePlugin '
25+ @registerHandler = jasmine . createSpy ( ' register handler ' )
26+ @unregisterHandler = jasmine . createSpy ( ' unregister handler ' )
2027
2128 describe ' registered before activation' , ->
2229
2330 beforeEach ->
31+ Minimap .on ' plugin:added' , @registerHandler
2432 Minimap .registerPlugin ' dummy' , @plugin
2533
2634 it ' should be available in the minimap' , ->
2735 expect (Minimap .plugins [' dummy' ]).toBe (@plugin )
2836
37+ it ' should have emit an event' , ->
38+ expect (@registerHandler ).toHaveBeenCalled ()
39+
2940 it ' should have created a default config for the plugin' , ->
3041 expect (Minimap .configDefaults .plugins .dummy ).toBeDefined ()
3142
3243 it ' should have set the corresponding config' , ->
3344 expect (atom .config .get ' minimap.plugins.dummy' ).toBeDefined ()
3445
46+ describe ' triggering the corresponding plugin command' , ->
47+ beforeEach ->
48+ atom .workspaceView .trigger ' minimap:toggle-dummy'
49+
50+ it ' should have received a deactivation call' , ->
51+ expect (@plugin .deactivatePlugin ).toHaveBeenCalled ()
52+
3553 describe ' and then unregistered' , ->
3654 beforeEach ->
3755 Minimap .unregisterPlugin ' dummy'
@@ -46,31 +64,31 @@ describe "Minimap Plugins", ->
4664 it ' should not receive an activation call' , ->
4765 expect (@plugin .deactivatePlugin ).not .toHaveBeenCalled ()
4866
49- describe ' the registered plugin' , ->
50- it ' should have received an activation call' , ->
51- Minimap .registerPlugin ' dummy' , @plugin
52- expect (@plugin .activatePlugin ).toHaveBeenCalled ()
67+ describe ' the registered plugin' , ->
68+ it ' should have received an activation call' , ->
69+ Minimap .registerPlugin ' dummy' , @plugin
70+ expect (@plugin .activatePlugin ).toHaveBeenCalled ()
5371
54- describe ' when the config for it is false' , ->
55- beforeEach ->
56- atom .config .set ' minimap.plugins.dummy' , false
57- Minimap .registerPlugin ' dummy' , @plugin
72+ describe ' when the config for it is false' , ->
73+ beforeEach ->
74+ atom .config .set ' minimap.plugins.dummy' , false
75+ Minimap .registerPlugin ' dummy' , @plugin
5876
59- it ' should have received a deactivation call' , ->
60- expect (@plugin .deactivatePlugin ) .toHaveBeenCalled ()
77+ it ' should not have received an activation call' , ->
78+ expect (@plugin .activatePlugin ). not .toHaveBeenCalled ()
6179
62- describe ' when the config is modified after registration' , ->
63- beforeEach ->
64- Minimap .registerPlugin ' dummy' , @plugin
65- atom .config .set ' minimap.plugins.dummy' , false
80+ describe ' when the config is modified after registration' , ->
81+ beforeEach ->
82+ Minimap .registerPlugin ' dummy' , @plugin
83+ atom .config .set ' minimap.plugins.dummy' , false
6684
67- it ' should have received a deactivation call' , ->
85+ it ' should have received a deactivation call' , ->
6886 expect (@plugin .deactivatePlugin ).toHaveBeenCalled ()
6987
70- describe ' on minimap activation' , ->
71- beforeEach ->
72- waitsForPromise ->
73- promise = atom .packages .activatePackage (' minimap' )
74- expect (atom .workspaceView .find (' .minimap' )).not .toExist ()
75- atom .workspaceView .trigger ' minimap:toggle'
76- promise
88+ describe ' on minimap activation' , ->
89+ beforeEach ->
90+ waitsForPromise ->
91+ promise = atom .packages .activatePackage (' minimap' )
92+ expect (atom .workspaceView .find (' .minimap' )).not .toExist ()
93+ atom .workspaceView .trigger ' minimap:toggle'
94+ promise
0 commit comments