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