2
2
/// <reference path="../typings/angularjs/angular.d.ts"/>
3
3
/// <reference path="../typings/jasmine/jasmine.d.ts"/>
4
4
describe ( 'directive' , function ( ) {
5
- var $compile ;
5
+ var $compile ,
6
+ $rootScope ;
6
7
7
8
beforeEach ( module ( 'wt.responsive' ) ) ;
8
- beforeEach ( inject ( function ( _$compile_ ) {
9
+ beforeEach ( inject ( function ( _$rootScope_ , _$ compile_) {
9
10
$compile = _$compile_ ;
11
+ $rootScope = _$rootScope_ ;
10
12
} ) ) ;
11
-
13
+
12
14
it ( 'supports colspan' , function ( ) {
13
15
var markup = [
14
16
'<table wt-responsive-table>' ,
@@ -44,4 +46,40 @@ describe('directive', function () {
44
46
expect ( firstDataRow . eq ( 0 ) . attr ( 'data-title' ) ) . toBe ( 'First title' ) ;
45
47
expect ( firstDataRow . eq ( 1 ) . attr ( 'data-title' ) ) . toBe ( 'Forth title' ) ;
46
48
} ) ;
49
+
50
+ it ( 'supports ng-repeat applied on TR' , function ( ) {
51
+ var markup = [
52
+ '<table wt-responsive-table>' ,
53
+ ' <thead>' ,
54
+ ' <tr>' ,
55
+ ' <th>First title</th>' ,
56
+ ' <th>Second title</th>' ,
57
+ ' <th>Third title</th>' ,
58
+ ' <th>Forth title</th>' ,
59
+ ' </tr>' ,
60
+ ' </thead>' ,
61
+ ' <tbody>' ,
62
+ ' <tr ng-repeat="item in rows">' ,
63
+ ' <td>First column</td>' ,
64
+ ' <td>Second column</td>' ,
65
+ ' <td>Third column</td>' ,
66
+ ' <td>Forth column</td>' ,
67
+ ' </tr>' ,
68
+ ' </tbody>' ,
69
+ '</table>'
70
+ ] . join ( '' ) ;
71
+ var element = angular . element ( markup ) ;
72
+ var scope = $rootScope . $new ( ) ;
73
+ scope . rows = [ 0 , 1 ] ;
74
+
75
+ var firstDataRow = element . find ( 'tbody tr:first td' ) ;
76
+ expect ( firstDataRow . attr ( 'data-title' ) ) . toBeUndefined ( ) ;
77
+
78
+ $compile ( element ) ( scope ) ;
79
+
80
+ expect ( firstDataRow . eq ( 0 ) . attr ( 'data-title' ) ) . toBe ( 'First title' ) ;
81
+ expect ( firstDataRow . eq ( 1 ) . attr ( 'data-title' ) ) . toBe ( 'Second title' ) ;
82
+ expect ( firstDataRow . eq ( 2 ) . attr ( 'data-title' ) ) . toBe ( 'Third title' ) ;
83
+ expect ( firstDataRow . eq ( 3 ) . attr ( 'data-title' ) ) . toBe ( 'Forth title' ) ;
84
+ } ) ;
47
85
} ) ;
0 commit comments