@@ -136,6 +136,91 @@ describe('update menus defaults', function() {
136136 expect ( layoutOut . updatemenus [ 0 ] . bgcolor ) . toEqual ( 'blue' ) ;
137137 expect ( layoutOut . updatemenus [ 1 ] . bgcolor ) . toEqual ( 'red' ) ;
138138 } ) ;
139+
140+ it ( 'should default \'type\' to \'dropdown\'' , function ( ) {
141+ layoutIn . updatemenus = [ {
142+ buttons : [ { method : 'relayout' , args : [ 'title' , 'Hello World' ] } ]
143+ } ] ;
144+
145+ supply ( layoutIn , layoutOut ) ;
146+
147+ expect ( layoutOut . updatemenus [ 0 ] . type ) . toEqual ( 'dropdown' ) ;
148+ } ) ;
149+
150+ it ( 'should default \'orientation\' to \'v\'' , function ( ) {
151+ layoutIn . updatemenus = [ {
152+ buttons : [ { method : 'relayout' , args : [ 'title' , 'Hello World' ] } ]
153+ } ] ;
154+
155+ supply ( layoutIn , layoutOut ) ;
156+
157+ expect ( layoutOut . updatemenus [ 0 ] . orientation ) . toEqual ( 'v' ) ;
158+ } ) ;
159+
160+ it ( 'should default \'showactive\' to true' , function ( ) {
161+ layoutIn . updatemenus = [ {
162+ buttons : [ { method : 'relayout' , args : [ 'title' , 'Hello World' ] } ]
163+ } ] ;
164+
165+ supply ( layoutIn , layoutOut ) ;
166+
167+ expect ( layoutOut . updatemenus [ 0 ] . showactive ) . toEqual ( true ) ;
168+ } ) ;
169+
170+ it ( 'should default \'openreverse\' to false' , function ( ) {
171+ layoutIn . updatemenus = [ {
172+ buttons : [ { method : 'relayout' , args : [ 'title' , 'Hello World' ] } ]
173+ } ] ;
174+
175+ supply ( layoutIn , layoutOut ) ;
176+
177+ expect ( layoutOut . updatemenus [ 0 ] . openreverse ) . toEqual ( false ) ;
178+ } ) ;
179+ } ) ;
180+
181+ describe ( 'update menus buttons' , function ( ) {
182+ var mock = require ( '@mocks/updatemenus_positioning.json' ) ;
183+ var gd ;
184+ var allMenus , buttonMenus , dropdownMenus ;
185+
186+ beforeEach ( function ( done ) {
187+ gd = createGraphDiv ( ) ;
188+
189+ // move update menu #2 to click on them separately
190+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
191+ mockCopy . layout . updatemenus [ 1 ] . x = 1 ;
192+
193+ allMenus = mockCopy . layout . updatemenus ;
194+ buttonMenus = allMenus . filter ( function ( opts ) { return opts . type === 'buttons' ; } ) ;
195+ dropdownMenus = allMenus . filter ( function ( opts ) { return opts . type !== 'buttons' ; } ) ;
196+
197+ Plotly . plot ( gd , mockCopy . data , mockCopy . layout ) . then ( done ) ;
198+ } ) ;
199+
200+ afterEach ( function ( ) {
201+ Plotly . purge ( gd ) ;
202+ destroyGraphDiv ( ) ;
203+ } ) ;
204+
205+ it ( 'creates button menus' , function ( done ) {
206+ assertNodeCount ( '.' + constants . containerClassName , 1 ) ;
207+
208+ // 12 menus, but button menus don't have headers, so there are only six headers:
209+ assertNodeCount ( '.' + constants . headerClassName , dropdownMenus . length ) ;
210+
211+ // Count the *total* number of buttons we expect for this mock:
212+ var buttonCount = 0 ;
213+ buttonMenus . forEach ( function ( menu ) { buttonCount += menu . buttons . length ; } ) ;
214+
215+ assertNodeCount ( '.' + constants . buttonClassName , buttonCount ) ;
216+
217+ done ( ) ;
218+
219+ } ) ;
220+
221+ function assertNodeCount ( query , cnt ) {
222+ expect ( d3 . selectAll ( query ) . size ( ) ) . toEqual ( cnt ) ;
223+ }
139224} ) ;
140225
141226describe ( 'update menus interactions' , function ( ) {
0 commit comments