@@ -196,7 +196,7 @@ describe('ng-table-dynamic', function() {
196
196
expect ( angular . element ( filterRow . find ( 'th' ) [ 1 ] ) . find ( 'select' ) . length ) . toBe ( 1 ) ;
197
197
} ) ) ;
198
198
} ) ;
199
- describe ( 'add column' , function ( ) {
199
+ describe ( 'changing column list ' , function ( ) {
200
200
var elm ;
201
201
beforeEach ( inject ( function ( $compile , $q , NgTableParams ) {
202
202
elm = angular . element (
@@ -250,7 +250,7 @@ describe('ng-table-dynamic', function() {
250
250
scope . $digest ( ) ;
251
251
} ) ) ;
252
252
253
- it ( 'should create table header' , function ( ) {
253
+ it ( 'adding new column should update table header' , function ( ) {
254
254
var newCol = {
255
255
'class' : 'moneyadd' ,
256
256
field : 'money' ,
@@ -274,15 +274,49 @@ describe('ng-table-dynamic', function() {
274
274
expect ( angular . element ( titles [ 1 ] ) . text ( ) . trim ( ) ) . toBe ( 'Age' ) ;
275
275
expect ( angular . element ( titles [ 2 ] ) . text ( ) . trim ( ) ) . toBe ( 'Money' ) ;
276
276
277
- expect ( angular . element ( rows [ 1 ] ) . hasClass ( 'ng-table-filters' ) ) . toBeTruthy ( ) ;
278
- var filters = angular . element ( rows [ 1 ] ) . find ( 'th' ) ;
277
+ var filterRow = angular . element ( rows [ 1 ] ) ;
278
+ expect ( filterRow . hasClass ( 'ng-table-filters' ) ) . toBeTruthy ( ) ;
279
+ expect ( filterRow . hasClass ( "ng-hide" ) ) . toBe ( false ) ;
280
+
281
+ var filters = filterRow . find ( 'th' ) ;
279
282
expect ( filters . length ) . toBe ( 3 ) ;
280
283
expect ( angular . element ( filters [ 0 ] ) . hasClass ( 'filter' ) ) . toBeTruthy ( ) ;
281
284
expect ( angular . element ( filters [ 1 ] ) . hasClass ( 'filter' ) ) . toBeTruthy ( ) ;
282
285
expect ( angular . element ( filters [ 2 ] ) . hasClass ( 'filter' ) ) . toBeTruthy ( ) ;
283
286
284
287
} ) ;
285
288
289
+ it ( 'removing new column should update table header' , function ( ) {
290
+ scope . cols . splice ( 0 , 1 ) ;
291
+ scope . $digest ( ) ;
292
+ var thead = elm . find ( 'thead' ) ;
293
+ expect ( thead . length ) . toBe ( 1 ) ;
294
+
295
+ var rows = thead . find ( 'tr' ) ;
296
+ var titles = angular . element ( rows [ 0 ] ) . find ( 'th' ) ;
297
+ expect ( titles . length ) . toBe ( 1 ) ;
298
+ expect ( angular . element ( titles [ 0 ] ) . text ( ) . trim ( ) ) . toBe ( 'Age' ) ;
299
+
300
+ var filterRow = angular . element ( rows [ 1 ] ) ;
301
+ expect ( filterRow . hasClass ( "ng-hide" ) ) . toBe ( true ) ;
302
+ } ) ;
303
+
304
+ it ( 'setting columns to null should remove all table columns from header' , function ( ) {
305
+ scope . cols = null ;
306
+ scope . $digest ( ) ;
307
+ var thead = elm . find ( 'thead' ) ;
308
+ expect ( thead . length ) . toBe ( 1 ) ;
309
+
310
+ var rows = thead . find ( 'tr' ) ;
311
+ var titles = angular . element ( rows [ 0 ] ) . find ( 'th' ) ;
312
+ expect ( titles . length ) . toBe ( 0 ) ;
313
+
314
+ var filterRow = angular . element ( rows [ 1 ] ) ;
315
+ expect ( filterRow . hasClass ( "ng-hide" ) ) . toBe ( true ) ;
316
+
317
+ expect ( filterRow . find ( 'th' ) . length ) . toBe ( 0 ) ;
318
+ } ) ;
319
+
286
320
} ) ;
287
321
describe ( 'title-alt' , function ( ) {
288
322
0 commit comments