@@ -16,7 +16,7 @@ app.listen(12345);
1616
1717
1818describe ( 'Hooks' , ( ) => {
19-
19+
2020 it ( "should have some hooks registered" , ( done ) => {
2121 Parse . Hooks . getFunctions ( ) . then ( ( res ) => {
2222 expect ( res . constructor ) . toBe ( Array . prototype . constructor ) ;
@@ -26,7 +26,7 @@ describe('Hooks', () => {
2626 done ( ) ;
2727 } ) ;
2828 } ) ;
29-
29+
3030 it ( "should have some triggers registered" , ( done ) => {
3131 Parse . Hooks . getTriggers ( ) . then ( ( res ) => {
3232 expect ( res . constructor ) . toBe ( Array . prototype . constructor ) ;
@@ -59,7 +59,7 @@ describe('Hooks', () => {
5959 } ) . then ( ( res ) => {
6060 expect ( res . functionName ) . toBe ( "My-Test-Function" ) ;
6161 expect ( res . url ) . toBe ( "http://anotherurl" )
62-
62+
6363 return Parse . Hooks . deleteFunction ( "My-Test-Function" ) ;
6464 } , ( err ) => {
6565 fail ( err ) ;
@@ -81,7 +81,7 @@ describe('Hooks', () => {
8181 done ( ) ;
8282 } )
8383 } ) ;
84-
84+
8585 it ( "should CRUD a trigger registration" , ( done ) => {
8686 // Create
8787 Parse . Hooks . createTrigger ( "MyClass" , "beforeDelete" , "http://someurl" ) . then ( ( res ) => {
@@ -105,7 +105,7 @@ describe('Hooks', () => {
105105 } ) . then ( ( res ) => {
106106 expect ( res . className ) . toBe ( "MyClass" ) ;
107107 expect ( res . url ) . toBe ( "http://anotherurl" )
108-
108+
109109 return Parse . Hooks . deleteTrigger ( "MyClass" , "beforeDelete" ) ;
110110 } , ( err ) => {
111111 fail ( err ) ;
@@ -127,7 +127,7 @@ describe('Hooks', () => {
127127 done ( ) ;
128128 } ) ;
129129 } ) ;
130-
130+
131131 it ( "should fail to register hooks without Master Key" , ( done ) => {
132132 request . post ( Parse . serverURL + "/hooks/functions" , {
133133 headers : {
@@ -141,7 +141,7 @@ describe('Hooks', () => {
141141 done ( ) ;
142142 } )
143143 } ) ;
144-
144+
145145 it ( "should fail trying to create two times the same function" , ( done ) => {
146146 Parse . Hooks . createFunction ( "my_new_function" , "http://url.com" ) . then ( ( ) => {
147147 return Parse . Hooks . createFunction ( "my_new_function" , "http://url.com" )
@@ -162,7 +162,7 @@ describe('Hooks', () => {
162162 done ( ) ;
163163 } )
164164 } ) ;
165-
165+
166166 it ( "should fail trying to create two times the same trigger" , ( done ) => {
167167 Parse . Hooks . createTrigger ( "MyClass" , "beforeSave" , "http://url.com" ) . then ( ( ) => {
168168 return Parse . Hooks . createTrigger ( "MyClass" , "beforeSave" , "http://url.com" )
@@ -181,7 +181,7 @@ describe('Hooks', () => {
181181 done ( ) ;
182182 } )
183183 } ) ;
184-
184+
185185 it ( "should fail trying to update a function that don't exist" , ( done ) => {
186186 Parse . Hooks . updateFunction ( "A_COOL_FUNCTION" , "http://url.com" ) . then ( ( ) => {
187187 fail ( "Should not succeed" )
@@ -198,7 +198,7 @@ describe('Hooks', () => {
198198 done ( ) ;
199199 } ) ;
200200 } ) ;
201-
201+
202202 it ( "should fail trying to update a trigger that don't exist" , ( done ) => {
203203 Parse . Hooks . updateTrigger ( "AClassName" , "beforeSave" , "http://url.com" ) . then ( ( ) => {
204204 fail ( "Should not succeed" )
@@ -215,8 +215,8 @@ describe('Hooks', () => {
215215 done ( ) ;
216216 } ) ;
217217 } ) ;
218-
219-
218+
219+
220220 it ( "should fail trying to create a malformed function" , ( done ) => {
221221 Parse . Hooks . createFunction ( "MyFunction" ) . then ( ( res ) => {
222222 fail ( res ) ;
@@ -226,7 +226,7 @@ describe('Hooks', () => {
226226 done ( ) ;
227227 } ) ;
228228 } ) ;
229-
229+
230230 it ( "should fail trying to create a malformed function (REST)" , ( done ) => {
231231 request . post ( Parse . serverURL + "/hooks/functions" , {
232232 headers : {
@@ -241,16 +241,16 @@ describe('Hooks', () => {
241241 done ( ) ;
242242 } )
243243 } ) ;
244-
245-
244+
245+
246246 it ( "should create hooks and properly preload them" , ( done ) => {
247-
247+
248248 var promises = [ ] ;
249249 for ( var i = 0 ; i < 5 ; i ++ ) {
250250 promises . push ( Parse . Hooks . createTrigger ( "MyClass" + i , "beforeSave" , "http://url.com/beforeSave/" + i ) ) ;
251251 promises . push ( Parse . Hooks . createFunction ( "AFunction" + i , "http://url.com/function" + i ) ) ;
252252 }
253-
253+
254254 Parse . Promise . when ( promises ) . then ( function ( results ) {
255255 for ( var i = 0 ; i < 5 ; i ++ ) {
256256 // Delete everything from memory, as the server just started
@@ -263,7 +263,7 @@ describe('Hooks', () => {
263263 return hooksController . load ( )
264264 } , ( err ) => {
265265 console . error ( err ) ;
266- fail ( ) ;
266+ fail ( 'Should properly create all hooks' ) ;
267267 done ( ) ;
268268 } ) . then ( function ( ) {
269269 for ( var i = 0 ; i < 5 ; i ++ ) {
@@ -273,17 +273,17 @@ describe('Hooks', () => {
273273 done ( ) ;
274274 } , ( err ) => {
275275 console . error ( err ) ;
276- fail ( ) ;
276+ fail ( 'should properly load all hooks' ) ;
277277 done ( ) ;
278278 } )
279279 } ) ;
280-
280+
281281 it ( "should run the function on the test server" , ( done ) => {
282-
282+
283283 app . post ( "/SomeFunction" , function ( req , res ) {
284284 res . json ( { success :"OK!" } ) ;
285285 } ) ;
286-
286+
287287 Parse . Hooks . createFunction ( "SOME_TEST_FUNCTION" , hookServerURL + "/SomeFunction" ) . then ( function ( ) {
288288 return Parse . Cloud . run ( "SOME_TEST_FUNCTION" )
289289 } , ( err ) => {
@@ -299,9 +299,9 @@ describe('Hooks', () => {
299299 done ( ) ;
300300 } )
301301 } ) ;
302-
302+
303303 it ( "should run the function on the test server" , ( done ) => {
304-
304+
305305 app . post ( "/SomeFunctionError" , function ( req , res ) {
306306 res . json ( { error : { code : 1337 , error : "hacking that one!" } } ) ;
307307 } ) ;
@@ -322,8 +322,8 @@ describe('Hooks', () => {
322322 done ( ) ;
323323 } ) ;
324324 } ) ;
325-
326-
325+
326+
327327 it ( "should run the beforeSave hook on the test server" , ( done ) => {
328328 var triggerCount = 0 ;
329329 app . post ( "/BeforeSaveSome" , function ( req , res ) {
@@ -350,7 +350,7 @@ describe('Hooks', () => {
350350 done ( ) ;
351351 } ) ;
352352 } ) ;
353-
353+
354354 it ( "should run the afterSave hook on the test server" , ( done ) => {
355355 var triggerCount = 0 ;
356356 var newObjectId ;
@@ -387,4 +387,4 @@ describe('Hooks', () => {
387387 done ( ) ;
388388 } ) ;
389389 } ) ;
390- } ) ;
390+ } ) ;
0 commit comments