@@ -76,7 +76,7 @@ describe('angularCharts', function() {
7676 expect ( compileChart ) . toThrow ( )
7777 } )
7878
79- it ( 'should throw width/height error' , function ( ) {
79+ it ( 'should not throw width/height error if the chart has a width/height ' , function ( ) {
8080 angular . element ( document . body ) . append ( '<style type="text/css">#chart { width:150px; height: 300px}</style>' )
8181 expect ( compileChart ) . not . toThrow ( )
8282 } )
@@ -89,10 +89,6 @@ describe('angularCharts', function() {
8989 $chart_childrens = angular . element ( $chart ) . children ( )
9090 } )
9191
92- it ( 'should have the right DOM title' , function ( ) {
93- expect ( $chart . querySelector ( '.ac-title' ) . innerText ) . toEqual ( 'Not Products' )
94- } )
95-
9692 it ( 'should have the right elements in the legend' , function ( ) {
9793
9894 var $legendItems = $chart . querySelector ( '.ac-legend tbody' ) . children
@@ -209,4 +205,32 @@ describe('angularCharts', function() {
209205
210206 } )
211207
208+ describe ( 'title' , function ( ) {
209+ beforeEach ( function ( ) {
210+ angular . element ( document . body ) . append ( '<style type="text/css">#chart { width:150px; height: 300px}</style>' ) ;
211+ $scope . chartType = 'area' ;
212+ } ) ;
213+
214+ it ( 'should set the title in the title element' , function ( ) {
215+ $scope . config . title = 'My Title' ;
216+
217+ compileChart ( ) ;
218+ $scope . $digest ( ) ;
219+
220+ $chart = document . getElementById ( 'chart' )
221+ expect ( $chart . querySelectorAll ( '.ac-title' ) . length ) . toBe ( 1 ) ;
222+ expect ( $chart . querySelector ( '.ac-title' ) . innerText ) . toEqual ( 'My Title' )
223+ } ) ;
224+
225+ it ( 'should not have a title element if the title is an empty string or false' , function ( ) {
226+ $scope . config . title = false ;
227+
228+ compileChart ( ) ;
229+ $scope . $digest ( ) ;
230+
231+ $chart = document . getElementById ( 'chart' ) ;
232+ expect ( $chart . querySelectorAll ( '.ac-title' ) . length ) . toBe ( 0 ) ;
233+ } ) ;
234+
235+ } ) ;
212236} )
0 commit comments