@@ -29,12 +29,7 @@ describe('Topcoder Form Stockart Directive', function() {
2929 var initialStockart = isolateScope . formStockarts [ 0 ]
3030
3131 expect ( initialStockart . id ) . to . equal ( 0 )
32- expect ( initialStockart . description ) . to . equal ( '' )
3332 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 )
3833 } )
3934
4035 it ( 'a regular expression' , function ( ) {
@@ -79,21 +74,21 @@ describe('Topcoder Form Stockart Directive', function() {
7974 it ( 'resets the stockart fieldset when it\'s the only one' , function ( ) {
8075 var stockart = isolateScope . formStockarts [ 0 ]
8176
82- expect ( stockart . description ) . to . equal ( '' )
77+ expect ( stockart . sourceUrl ) . to . equal ( '' )
8378
84- stockart . description = 'a funny cat picture '
79+ stockart . sourceUrl = 'www.myURL.com '
8580 scope . $digest ( )
8681
87- expect ( stockart . description ) . to . equal ( 'a funny cat picture ' )
82+ expect ( stockart . sourceUrl ) . to . equal ( 'www.myURL.com ' )
8883
8984 isolateScope . deleteStockartFieldset ( 0 )
9085 scope . $digest ( )
9186
92- expect ( isolateScope . formStockarts [ 0 ] . description ) . to . equal ( '' )
87+ expect ( isolateScope . formStockarts [ 0 ] . sourceUrl ) . to . equal ( '' )
9388 } )
9489 } )
9590
96- describe ( 'isButtonDisabled' , function ( ) {
91+ describe . only ( 'isButtonDisabled' , function ( ) {
9792 var button
9893
9994 beforeEach ( function ( ) {
@@ -108,37 +103,20 @@ describe('Topcoder Form Stockart Directive', function() {
108103 expect ( button . disabled ) . to . be . true
109104 } )
110105
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 ( ) {
123107 expect ( button . disabled ) . to . be . true
124- } )
125108
126- it ( 'enables the button when all fields are filled out' , function ( ) {
127- isolateScope . formStockarts [ 0 ] . description = 'test description'
128109 isolateScope . formStockarts [ 0 ] . sourceUrl = 'url'
129- isolateScope . formStockarts [ 0 ] . fileNumber = '123'
130110 scope . $digest ( )
131111
132112 expect ( button . disabled ) . to . be . false
133113 } )
134114
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 ( ) {
136116 expect ( button . disabled ) . to . be . true
137117
138118 // Fill out first fieldset
139- isolateScope . formStockarts [ 0 ] . description = 'test description'
140119 isolateScope . formStockarts [ 0 ] . sourceUrl = 'url.com'
141- isolateScope . formStockarts [ 0 ] . fileNumber = '123'
142120 scope . $digest ( )
143121
144122 expect ( button . disabled ) . to . be . false
@@ -149,81 +127,16 @@ describe('Topcoder Form Stockart Directive', function() {
149127 expect ( button . disabled ) . to . be . true
150128
151129 // Fill out second fieldset
152- isolateScope . formStockarts [ 1 ] . description = 'test description2'
153130 isolateScope . formStockarts [ 1 ] . sourceUrl = 'url2.com'
154- isolateScope . formStockarts [ 1 ] . fileNumber = '1232'
155131 scope . $digest ( )
156132
157133 expect ( button . disabled ) . to . be . false
158134
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 = ''
161137 scope . $digest ( )
162138
163139 expect ( button . disabled ) . to . be . true
164140 } )
165141 } )
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- } )
229142} )
0 commit comments