@@ -332,23 +332,48 @@ describe("GET /users/me/campaigns - target", () => {
332332
333333 describe ( "Target by age" , ( ) => {
334334 beforeAll ( async ( ) => {
335- await tryber . tables . WpAppqEvdProfile . do ( ) . insert ( {
336- id : 1 ,
337- wp_user_id : 1 ,
338- email : "" ,
339- education_id : 1 ,
340- employment_id : 1 ,
341- country : "Italy" ,
342- birth_date : "2000-01-01" ,
343- } ) ;
335+ await tryber . tables . CampaignDossierDataAge . do ( ) . insert ( [
336+ {
337+ campaign_dossier_data_id : 1 ,
338+ min : 20 ,
339+ max : 27 ,
340+ } ,
341+ {
342+ campaign_dossier_data_id : 1 ,
343+ min : 29 ,
344+ max : 30 ,
345+ } ,
346+ {
347+ campaign_dossier_data_id : 1 ,
348+ min : 50 ,
349+ max : 60 ,
350+ } ,
351+ ] ) ;
344352 } ) ;
345353 afterAll ( async ( ) => {
346- await tryber . tables . WpAppqEvdProfile . do ( ) . delete ( ) ;
354+ await tryber . tables . CampaignDossierDataAge . do ( ) . delete ( ) ;
347355 } ) ;
348356 describe ( "Tester with right age value" , ( ) => {
349- beforeAll ( async ( ) => { } ) ;
357+ beforeAll ( async ( ) => {
358+ const today = new Date ( ) ;
359+ const birthDate = new Date (
360+ today . getFullYear ( ) - 29 ,
361+ today . getMonth ( ) ,
362+ today . getDate ( ) - 1
363+ ) ;
364+ const birthDateString = birthDate . toISOString ( ) . split ( "T" ) [ 0 ] ;
365+ await tryber . tables . WpAppqEvdProfile . do ( ) . insert ( {
366+ id : 1 ,
367+ wp_user_id : 1 ,
368+ email : "" ,
369+ education_id : 1 ,
370+ employment_id : 1 ,
371+ country : "Italy" ,
372+ birth_date : birthDateString ,
373+ } ) ;
374+ } ) ;
350375 afterAll ( async ( ) => {
351- await tryber . tables . CampaignDossierDataAge . do ( ) . delete ( ) ;
376+ await tryber . tables . WpAppqEvdProfile . do ( ) . delete ( ) ;
352377 } ) ;
353378
354379 it ( "Should show the campaign" , async ( ) => {
@@ -361,14 +386,25 @@ describe("GET /users/me/campaigns - target", () => {
361386
362387 describe ( "Tester with wrong age value" , ( ) => {
363388 beforeAll ( async ( ) => {
364- await tryber . tables . CampaignDossierDataAge . do ( ) . insert ( {
365- campaign_dossier_data_id : 1 ,
366- max : 200 ,
367- min : 100 ,
389+ const today = new Date ( ) ;
390+ const birthDate = new Date (
391+ today . getFullYear ( ) - 100 ,
392+ today . getMonth ( ) ,
393+ today . getDate ( ) - 1
394+ ) ;
395+ const birthDateString = birthDate . toISOString ( ) . split ( "T" ) [ 0 ] ;
396+ await tryber . tables . WpAppqEvdProfile . do ( ) . insert ( {
397+ id : 1 ,
398+ wp_user_id : 1 ,
399+ email : "" ,
400+ education_id : 1 ,
401+ employment_id : 1 ,
402+ country : "Italy" ,
403+ birth_date : birthDateString ,
368404 } ) ;
369405 } ) ;
370406 afterAll ( async ( ) => {
371- await tryber . tables . CampaignDossierDataAge . do ( ) . delete ( ) ;
407+ await tryber . tables . WpAppqEvdProfile . do ( ) . delete ( ) ;
372408 } ) ;
373409
374410 it ( "Should not show the campaign" , async ( ) => {
@@ -378,14 +414,6 @@ describe("GET /users/me/campaigns - target", () => {
378414 expect ( response . status ) . toBe ( 404 ) ;
379415 } ) ;
380416 } ) ;
381- describe ( "Campaign without required age value" , ( ) => {
382- it ( "Should show the campaign" , async ( ) => {
383- const response = await request ( app )
384- . get ( "/users/me/campaigns" )
385- . set ( "Authorization" , "Bearer tester" ) ;
386- expect ( response . status ) . toBe ( 200 ) ;
387- } ) ;
388- } ) ;
389417 } ) ;
390418
391419 describe ( "Target by gender" , ( ) => {
0 commit comments