@@ -818,6 +818,83 @@ describe('Core.scale', function() {
818818 } ) ;
819819 } ) ;
820820 describe ( 'Scale Title stroke' , ( ) => {
821+ function getScaleTitleCalls ( position , align , reverse ) {
822+ const axis = position === 'left' || position === 'right' ? 'y' : 'x' ;
823+ const chart = window . acquireChart ( {
824+ type : 'scatter' ,
825+ data : {
826+ datasets : [ {
827+ data : [ { x : 0 , y : 0 } , { x : 10 , y : 10 } ]
828+ } ]
829+ } ,
830+ options : {
831+ events : [ ] ,
832+ animation : false ,
833+ plugins : {
834+ legend : false
835+ } ,
836+ scales : {
837+ x : {
838+ display : axis === 'x' ,
839+ position : axis === 'x' ? position : 'bottom' ,
840+ min : 0 ,
841+ max : 10 ,
842+ reverse : axis === 'x' ? reverse : false ,
843+ ticks : {
844+ display : false
845+ } ,
846+ grid : {
847+ display : false
848+ } ,
849+ border : {
850+ display : false
851+ } ,
852+ title : {
853+ display : axis === 'x' ,
854+ text : 'title' ,
855+ align
856+ }
857+ } ,
858+ y : {
859+ display : axis === 'y' ,
860+ position : axis === 'y' ? position : 'left' ,
861+ min : 0 ,
862+ max : 10 ,
863+ reverse : axis === 'y' ? reverse : false ,
864+ ticks : {
865+ display : false
866+ } ,
867+ grid : {
868+ display : false
869+ } ,
870+ border : {
871+ display : false
872+ } ,
873+ title : {
874+ display : axis === 'y' ,
875+ text : 'title' ,
876+ align
877+ }
878+ }
879+ }
880+ }
881+ } ) ;
882+ const scale = chart . scales [ axis ] ;
883+
884+ scale . ctx = window . createMockContext ( ) ;
885+ chart . draw ( ) ;
886+
887+ return scale . ctx . getCalls ( ) . filter ( ( { name} ) => [ 'translate' , 'setTextAlign' , 'fillText' ] . includes ( name ) ) ;
888+ }
889+
890+ [ 'top' , 'bottom' , 'left' , 'right' ] . forEach ( function ( position ) {
891+ [ 'start' , 'end' ] . forEach ( function ( align ) {
892+ it ( 'should not reposition the ' + position + ' scale title when reverse=true and align=' + align , function ( ) {
893+ expect ( getScaleTitleCalls ( position , align , true ) ) . toEqual ( getScaleTitleCalls ( position , align , false ) ) ;
894+ } ) ;
895+ } ) ;
896+ } ) ;
897+
821898 function getChartWithScaleTitleStroke ( ) {
822899 return window . acquireChart ( {
823900 type : 'line' ,
0 commit comments