@@ -3,7 +3,6 @@ import rbush from 'rbush';
33import AnnotationModeController from '../AnnotationModeController' ;
44import * as util from '../../util' ;
55import {
6- CLASS_HIDDEN ,
76 CLASS_ACTIVE ,
87 CLASS_ANNOTATION_MODE ,
98 CLASS_ANNNOTATION_MODE_BACKGROUND ,
@@ -67,7 +66,6 @@ describe('controllers/AnnotationModeController', () => {
6766 permissions : { can_annotate : true } ,
6867 intl : intlMock ,
6968 } ) ;
70- expect ( controller . showButton ) . toBeCalled ( ) ;
7169 } ) ;
7270
7371 it ( 'should not show modeButton if none provided' , ( ) => {
@@ -129,95 +127,6 @@ describe('controllers/AnnotationModeController', () => {
129127 } ) ;
130128 } ) ;
131129
132- describe ( 'showButton()' , ( ) => {
133- let buttonEl ;
134-
135- beforeEach ( ( ) => {
136- controller . modeButton = {
137- type : {
138- title : 'Annotation Mode' ,
139- selector : '.selector' ,
140- } ,
141- } ;
142- buttonEl = document . createElement ( 'button' ) ;
143- buttonEl . title = controller . modeButton . title ;
144- buttonEl . classList . add ( CLASS_HIDDEN ) ;
145- buttonEl . classList . add ( 'selector' ) ;
146- buttonEl . addEventListener = jest . fn ( ) ;
147-
148- controller . permissions = { can_annotate : true } ;
149- controller . getButton = jest . fn ( ) . mockReturnValue ( buttonEl ) ;
150- } ) ;
151-
152- it ( 'should do nothing if user cannot annotate' , ( ) => {
153- controller . permissions . can_annotate = false ;
154- controller . showButton ( ) ;
155- expect ( buttonEl . classList ) . toContain ( CLASS_HIDDEN ) ;
156- } ) ;
157-
158- it ( 'should do nothing if the button is not in the container' , ( ) => {
159- controller . getButton = jest . fn ( ) ;
160- controller . showButton ( ) ;
161- expect ( buttonEl . classList ) . toContain ( CLASS_HIDDEN ) ;
162- } ) ;
163-
164- it ( 'should set up and show an annotate button' , ( ) => {
165- controller . showButton ( ) ;
166- expect ( buttonEl . classList ) . not . toContain ( CLASS_HIDDEN ) ;
167- expect ( buttonEl . addEventListener ) . toBeCalledWith ( 'click' , controller . toggleMode ) ;
168- } ) ;
169- it ( 'should set up and show an annotate button' , ( ) => {
170- controller . showButton ( ) ;
171- expect ( buttonEl . classList ) . not . toContain ( CLASS_HIDDEN ) ;
172- expect ( buttonEl . addEventListener ) . toBeCalledWith ( 'click' , controller . toggleMode ) ;
173- } ) ;
174- } ) ;
175-
176- describe ( 'hideButton()' , ( ) => {
177- let buttonEl ;
178-
179- beforeEach ( ( ) => {
180- controller . modeButton = {
181- type : {
182- title : 'Annotation Mode' ,
183- selector : '.selector' ,
184- } ,
185- } ;
186- buttonEl = document . createElement ( 'button' ) ;
187- buttonEl . title = controller . modeButton . title ;
188- buttonEl . classList . remove ( CLASS_HIDDEN ) ;
189- buttonEl . classList . add ( 'selector' ) ;
190- buttonEl . addEventListener = jest . fn ( ) ;
191-
192- controller . permissions = { can_annotate : true } ;
193- controller . getButton = jest . fn ( ) . mockReturnValue ( buttonEl ) ;
194- } ) ;
195-
196- it ( 'should do nothing if user cannot annotate' , ( ) => {
197- controller . permissions . can_annotate = false ;
198- controller . hideButton ( ) ;
199- expect ( buttonEl . classList ) . not . toContain ( CLASS_HIDDEN ) ;
200- } ) ;
201-
202- it ( 'should do nothing if button is not found' , ( ) => {
203- controller . getButton = jest . fn ( ) ;
204- controller . hideButton ( ) ;
205- expect ( buttonEl . classList ) . not . toContain ( CLASS_HIDDEN ) ;
206- } ) ;
207-
208- it ( 'should add the bp-is-hidden class to the button' , ( ) => {
209- controller . hideButton ( ) ;
210- expect ( buttonEl . classList ) . toContain ( CLASS_HIDDEN ) ;
211- } ) ;
212-
213- it ( 'should do nothing if no modeButton' , ( ) => {
214- controller . modeButton = undefined ;
215- controller . permissions . can_annotate = false ;
216- controller . hideButton ( ) ;
217- expect ( buttonEl . classList ) . not . toContain ( CLASS_HIDDEN ) ;
218- } ) ;
219- } ) ;
220-
221130 describe ( 'toggleMode()' , ( ) => {
222131 beforeEach ( ( ) => {
223132 controller . emit = jest . fn ( ) ;
0 commit comments