@@ -42,6 +42,27 @@ describe("DSL", function() {
42
42
describe ( 'repeater' , function ( ) {
43
43
44
44
var repeater = angular . scenario . dsl . repeater ;
45
+ var html ;
46
+ beforeEach ( function ( ) {
47
+ html = "<table>" +
48
+ "<tr class='epic'>" +
49
+ "<td class='hero-name'>" +
50
+ "<span ng:bind='hero'>John Marston</span>" +
51
+ "</td>" +
52
+ "<td class='game-name'>" +
53
+ "<span ng:bind='game'>Red Dead Redemption</span>" +
54
+ "</td>" +
55
+ "</tr>" +
56
+ "<tr class='epic'>" +
57
+ "<td class='hero-name'>" +
58
+ "<span ng:bind='hero'>Nathan Drake</span>" +
59
+ "</td>" +
60
+ "<td class='game-name'>" +
61
+ "<span ng:bind='game'>Uncharted</span>" +
62
+ "</td>" +
63
+ "</tr>" +
64
+ "</table>" ;
65
+ } ) ;
45
66
it ( 'should count' , function ( ) {
46
67
var future = repeater ( '.repeater-row' ) . count ( ) ;
47
68
expect ( future . name ) . toEqual ( "repeater '.repeater-row' count" ) ;
@@ -55,29 +76,31 @@ describe("DSL", function() {
55
76
expect ( future . value ) . toEqual ( 2 ) ;
56
77
} ) ;
57
78
58
- it ( 'should collect' , function ( ) {
59
- var future = repeater ( '.epic' ) . collect ( ) ;
60
- expect ( future . name ) . toEqual ( "repeater '.epic' collect" ) ;
61
- executeFuture ( future ,
62
- "<table>" +
63
- "<tr class='epic'>" +
64
- "<td ng:bind='hero'>John Marston</td>" +
65
- "<td ng:bind='game'>Red Dead Redemption</td>" +
66
- "</tr>" +
67
- "<tr class='epic'>" +
68
- "<td ng:bind='hero'>Nathan Drake</td>" +
69
- "<td ng:bind='game'>Uncharted 2</td>" +
70
- "</tr>" +
71
- "</table>" ,
72
- function ( value ) {
73
- future . fulfill ( value ) ;
79
+ function assertFutureState ( future , expectedName , expectedValue ) {
80
+ expect ( future . name ) . toEqual ( expectedName ) ;
81
+ executeFuture ( future , html , function ( value ) {
82
+ future . fulfill ( value ) ;
74
83
} ) ;
75
84
expect ( future . fulfilled ) . toBeTruthy ( ) ;
76
- expect ( future . value [ 0 ] . boundTo ( 'hero' ) ) . toEqual ( 'John Marston' ) ;
77
- expect ( future . value [ 0 ] . boundTo ( 'game' ) ) . toEqual ( 'Red Dead Redemption' ) ;
78
- expect ( future . value [ 1 ] . boundTo ( 'hero' ) ) . toEqual ( 'Nathan Drake' ) ;
79
- expect ( future . value [ 1 ] . boundTo ( 'game' ) ) . toEqual ( 'Uncharted 2' ) ;
85
+ expect ( future . value ) . toEqual ( expectedValue ) ;
86
+ }
87
+ it ( 'should collect bindings' , function ( ) {
88
+ assertFutureState ( repeater ( '.epic' ) . collect ( '{{hero}}' ) ,
89
+ "repeater '.epic' collect '{{hero}}'" ,
90
+ [ 'John Marston' , 'Nathan Drake' ] ) ;
91
+ assertFutureState ( repeater ( '.epic' ) . collect ( '{{game}}' ) ,
92
+ "repeater '.epic' collect '{{game}}'" ,
93
+ [ 'Red Dead Redemption' , 'Uncharted' ] ) ;
94
+ } ) ;
95
+ it ( 'should collect normal selectors' , function ( ) {
96
+ assertFutureState ( repeater ( '.epic' ) . collect ( '.hero-name' ) ,
97
+ "repeater '.epic' collect '.hero-name'" ,
98
+ [ 'John Marston' , 'Nathan Drake' ] ) ;
99
+ assertFutureState ( repeater ( '.epic' ) . collect ( '.game-name' ) ,
100
+ "repeater '.epic' collect '.game-name'" ,
101
+ [ 'Red Dead Redemption' , 'Uncharted' ] ) ;
80
102
} ) ;
103
+ it ( 'should collect normal attributes' , function ( ) { } ) ;
81
104
} ) ;
82
105
83
106
describe ( 'element' , function ( ) {
0 commit comments