@@ -234,7 +234,7 @@ describe("Offer endpoint tests", () => {
234234 } ) ;
235235 describe ( "jobMinDuration" , ( ) => {
236236 const FieldValidatorTester = BodyValidatorTester ( "jobMinDuration" ) ;
237- if ( BodyValidatorTester ( "jobType" ) !== "freelance " ) {
237+ if ( BodyValidatorTester ( "jobType" ) !== "FREELANCE " ) {
238238 FieldValidatorTester . isRequired ( ) ;
239239 FieldValidatorTester . mustBeNumber ( ) ;
240240 }
@@ -680,22 +680,31 @@ describe("Offer endpoint tests", () => {
680680 } ) ;
681681
682682 describe ( "Job Duration" , ( ) => {
683- test ( "should fail if jobMinDuration is greater than jobMaxDuration" , async ( ) => {
683+
684+ test ( "should succeed if jobMinDuration doesn't exist in freelance offer" , async ( ) => {
684685 const offer_params = generateTestOffer ( {
685- jobMinDuration : 10 ,
686+ jobType : "FREELANCE" ,
686687 jobMaxDuration : 8 ,
688+ jobMinDuration : null ,
687689 owner : test_company . _id ,
688690 } ) ;
689-
690691 const res = await request ( )
691692 . post ( "/offers/new" )
692693 . send ( withGodToken ( offer_params ) ) ;
694+ expect ( res . status ) . toBe ( HTTPStatus . OK ) ;
695+ } ) ;
696+
697+ test ( "should fail if jobMinDuration doesn't exist in any offer besides freelance" , async ( ) => {
698+ const offer_params = generateTestOffer ( {
699+ jobMaxDuration : 8 ,
700+ jobMinDuration : null ,
701+ owner : test_company . _id ,
702+ } ) ;
693703
704+ const res = await request ( )
705+ . post ( "/offers/new" )
706+ . send ( withGodToken ( offer_params ) ) ;
694707 expect ( res . status ) . toBe ( HTTPStatus . UNPROCESSABLE_ENTITY ) ;
695- expect ( res . body ) . toHaveProperty ( "error_code" , ErrorTypes . VALIDATION_ERROR ) ;
696- expect ( res . body ) . toHaveProperty ( "errors" ) ;
697- expect ( res . body . errors [ 0 ] ) . toHaveProperty ( "param" , "jobMaxDuration" ) ;
698- expect ( res . body . errors [ 0 ] ) . toHaveProperty ( "msg" , ValidationReasons . MUST_BE_GREATER_THAN_OR_EQUAL_TO ( "jobMinDuration" ) ) ;
699708 } ) ;
700709
701710 test ( "should succeed if jobMaxDuration is greater than jobMinDuration" , async ( ) => {
0 commit comments