@@ -29,12 +29,7 @@ describe('Topcoder Form Stockart Directive', function() {
29
29
var initialStockart = isolateScope . formStockarts [ 0 ]
30
30
31
31
expect ( initialStockart . id ) . to . equal ( 0 )
32
- expect ( initialStockart . description ) . to . equal ( '' )
33
32
expect ( initialStockart . sourceUrl ) . to . equal ( '' )
34
- expect ( initialStockart . fileNumber ) . to . equal ( '' )
35
- expect ( initialStockart . isPhotoDescriptionRequired ) . to . equal ( false )
36
- expect ( initialStockart . isPhotoURLRequired ) . to . equal ( false )
37
- expect ( initialStockart . isFileNumberRequired ) . to . equal ( false )
38
33
} )
39
34
40
35
it ( 'a regular expression' , function ( ) {
@@ -79,21 +74,21 @@ describe('Topcoder Form Stockart Directive', function() {
79
74
it ( 'resets the stockart fieldset when it\'s the only one' , function ( ) {
80
75
var stockart = isolateScope . formStockarts [ 0 ]
81
76
82
- expect ( stockart . description ) . to . equal ( '' )
77
+ expect ( stockart . sourceUrl ) . to . equal ( '' )
83
78
84
- stockart . description = 'a funny cat picture '
79
+ stockart . sourceUrl = 'www.myURL.com '
85
80
scope . $digest ( )
86
81
87
- expect ( stockart . description ) . to . equal ( 'a funny cat picture ' )
82
+ expect ( stockart . sourceUrl ) . to . equal ( 'www.myURL.com ' )
88
83
89
84
isolateScope . deleteStockartFieldset ( 0 )
90
85
scope . $digest ( )
91
86
92
- expect ( isolateScope . formStockarts [ 0 ] . description ) . to . equal ( '' )
87
+ expect ( isolateScope . formStockarts [ 0 ] . sourceUrl ) . to . equal ( '' )
93
88
} )
94
89
} )
95
90
96
- describe ( 'isButtonDisabled' , function ( ) {
91
+ describe . only ( 'isButtonDisabled' , function ( ) {
97
92
var button
98
93
99
94
beforeEach ( function ( ) {
@@ -108,37 +103,20 @@ describe('Topcoder Form Stockart Directive', function() {
108
103
expect ( button . disabled ) . to . be . true
109
104
} )
110
105
111
- it ( 'disables the button when 1 field is filled out' , function ( ) {
112
- isolateScope . formStockarts [ 0 ] . description = 'test description'
113
- scope . $digest ( )
114
-
115
- expect ( button . disabled ) . to . be . true
116
- } )
117
-
118
- it ( 'disables the button when 2 fields are filled out' , function ( ) {
119
- isolateScope . formStockarts [ 0 ] . description = 'test description'
120
- isolateScope . formStockarts [ 0 ] . sourceUrl = 'url'
121
- scope . $digest ( )
122
-
106
+ it ( 'enables the button when the url field is filled out' , function ( ) {
123
107
expect ( button . disabled ) . to . be . true
124
- } )
125
108
126
- it ( 'enables the button when all fields are filled out' , function ( ) {
127
- isolateScope . formStockarts [ 0 ] . description = 'test description'
128
109
isolateScope . formStockarts [ 0 ] . sourceUrl = 'url'
129
- isolateScope . formStockarts [ 0 ] . fileNumber = '123'
130
110
scope . $digest ( )
131
111
132
112
expect ( button . disabled ) . to . be . false
133
113
} )
134
114
135
- it ( 'disables the button when any field in any fieldset is empty' , function ( ) {
115
+ it ( 'disables the button when any url field in any fieldset is empty' , function ( ) {
136
116
expect ( button . disabled ) . to . be . true
137
117
138
118
// Fill out first fieldset
139
- isolateScope . formStockarts [ 0 ] . description = 'test description'
140
119
isolateScope . formStockarts [ 0 ] . sourceUrl = 'url.com'
141
- isolateScope . formStockarts [ 0 ] . fileNumber = '123'
142
120
scope . $digest ( )
143
121
144
122
expect ( button . disabled ) . to . be . false
@@ -149,81 +127,16 @@ describe('Topcoder Form Stockart Directive', function() {
149
127
expect ( button . disabled ) . to . be . true
150
128
151
129
// Fill out second fieldset
152
- isolateScope . formStockarts [ 1 ] . description = 'test description2'
153
130
isolateScope . formStockarts [ 1 ] . sourceUrl = 'url2.com'
154
- isolateScope . formStockarts [ 1 ] . fileNumber = '1232'
155
131
scope . $digest ( )
156
132
157
133
expect ( button . disabled ) . to . be . false
158
134
159
- // Empty a field in the first fieldset
160
- isolateScope . formStockarts [ 0 ] . fileNumber = ''
135
+ // Empty the field in the first fieldset
136
+ isolateScope . formStockarts [ 0 ] . sourceUrl = ''
161
137
scope . $digest ( )
162
138
163
139
expect ( button . disabled ) . to . be . true
164
140
} )
165
141
} )
166
-
167
- describe ( 'showMandatoryMessage' , function ( ) {
168
- describe ( 'sets the stockart required properties to false when all fields are' , function ( ) {
169
- var stockart
170
-
171
- beforeEach ( function ( ) {
172
- stockart = isolateScope . formStockarts [ 0 ]
173
- stockart . description = 'test description'
174
- stockart . sourceUrl = 'url.com'
175
- stockart . fileNumber = '123'
176
- scope . $digest ( )
177
- } )
178
-
179
- afterEach ( function ( ) {
180
- stockart = undefined
181
- } )
182
-
183
- it ( 'filled out' , function ( ) {
184
- expect ( stockart . isPhotoDescriptionRequired ) . to . be . false
185
- expect ( stockart . isPhotoURLRequired ) . to . be . false
186
- expect ( stockart . isFileNumberRequired ) . to . be . false
187
- } )
188
-
189
- it ( 'empty' , function ( ) {
190
- // Reset stockart fields
191
- stockart . description = ''
192
- stockart . sourceUrl = ''
193
- stockart . fileNumber = ''
194
- scope . $digest ( )
195
-
196
- expect ( stockart . isPhotoDescriptionRequired ) . to . be . false
197
- expect ( stockart . isPhotoURLRequired ) . to . be . false
198
- expect ( stockart . isFileNumberRequired ) . to . be . false
199
- } )
200
- } )
201
-
202
-
203
- describe ( 'sets the stockart required properties to false when all fields are' , function ( ) {
204
- var stockart
205
-
206
- beforeEach ( function ( ) {
207
- stockart = isolateScope . formStockarts [ 0 ]
208
- stockart . description = 'test description'
209
- stockart . sourceUrl = 'url.com'
210
- stockart . fileNumber = '123'
211
- scope . $digest ( )
212
- } )
213
-
214
- afterEach ( function ( ) {
215
- stockart = undefined
216
- } )
217
-
218
- it ( 'sets the stockart required properties to true if any field is blank' , function ( ) {
219
- // Reset stockart fields
220
- stockart . description = ''
221
- scope . $digest ( )
222
-
223
- expect ( stockart . isPhotoDescriptionRequired ) . to . be . true
224
- expect ( stockart . isPhotoURLRequired ) . to . be . true
225
- expect ( stockart . isFileNumberRequired ) . to . be . true
226
- } )
227
- } )
228
- } )
229
142
} )
0 commit comments