@@ -186,5 +186,45 @@ describe('Test shapes:', function() {
186186 expect ( countShapes ( gd ) ) . toEqual ( index ) ;
187187 } ) . then ( done ) ;
188188 } ) ;
189+
190+ it ( 'should be able to update a shape layer' , function ( done ) {
191+ var index = countShapes ( gd ) ,
192+ astr = 'shapes[' + index + ']' ,
193+ shape = getRandomShape ( ) ,
194+ shapesInLowerLayer = countShapePathsInLowerLayer ( ) ,
195+ shapesInUpperLayer = countShapePathsInUpperLayer ( ) ;
196+
197+ shape . xref = 'paper' ;
198+ shape . yref = 'paper' ;
199+
200+ Plotly . relayout ( gd , astr , shape ) . then ( function ( ) {
201+ expect ( countShapePathsInLowerLayer ( ) )
202+ . toEqual ( shapesInLowerLayer ) ;
203+ expect ( countShapePathsInUpperLayer ( ) )
204+ . toEqual ( shapesInUpperLayer + 1 ) ;
205+ expect ( getLastShape ( gd ) ) . toEqual ( shape ) ;
206+ expect ( countShapes ( gd ) ) . toEqual ( index + 1 ) ;
207+ } ) . then ( function ( ) {
208+ shape . layer = 'below' ;
209+ Plotly . relayout ( gd , astr + '.layer' , shape . layer ) ;
210+ } ) . then ( function ( ) {
211+ expect ( countShapePathsInLowerLayer ( ) )
212+ . toEqual ( shapesInLowerLayer + 1 ) ;
213+ expect ( countShapePathsInUpperLayer ( ) )
214+ . toEqual ( shapesInUpperLayer ) ;
215+ expect ( getLastShape ( gd ) ) . toEqual ( shape ) ;
216+ expect ( countShapes ( gd ) ) . toEqual ( index + 1 ) ;
217+ } ) . then ( function ( ) {
218+ shape . layer = 'above' ;
219+ Plotly . relayout ( gd , astr + '.layer' , shape . layer ) ;
220+ } ) . then ( function ( ) {
221+ expect ( countShapePathsInLowerLayer ( ) )
222+ . toEqual ( shapesInLowerLayer ) ;
223+ expect ( countShapePathsInUpperLayer ( ) )
224+ . toEqual ( shapesInUpperLayer + 1 ) ;
225+ expect ( getLastShape ( gd ) ) . toEqual ( shape ) ;
226+ expect ( countShapes ( gd ) ) . toEqual ( index + 1 ) ;
227+ } ) . then ( done ) ;
228+ } ) ;
189229 } ) ;
190230} ) ;
0 commit comments