@@ -561,88 +561,114 @@ describe('sendEmail', () => {
561561 } ) ;
562562 } ) ;
563563
564- it ( 'should send an email successfully' , async ( ) => {
565- // protected data setup
566- process . env . IEXEC_DATASET_FILENAME = 'data.zip' ;
564+ describe ( 'with valid email protectedData' , ( ) => {
565+ it ( 'should send an email successfully' , async ( ) => {
566+ // protected data setup
567+ process . env . IEXEC_DATASET_FILENAME = 'data.zip' ;
567568
568- await expect ( start ( ) ) . resolves . toBeUndefined ( ) ;
569+ await expect ( start ( ) ) . resolves . toBeUndefined ( ) ;
569570
570- const { result, computed, files } = await readOutputs (
571- process . env . IEXEC_OUT
572- ) ;
573- expect ( result ) . toStrictEqual ( {
574- success : true ,
575- protectedData : process . env . IEXEC_DATASET_FILENAME ,
576- } ) ;
577- expect ( computed ) . toStrictEqual ( {
578- 'deterministic-output-path' : `${ process . env . IEXEC_OUT } /result.json` ,
571+ const { result, computed, files } = await readOutputs (
572+ process . env . IEXEC_OUT
573+ ) ;
574+ expect ( result ) . toStrictEqual ( {
575+ success : true ,
576+ protectedData : process . env . IEXEC_DATASET_FILENAME ,
577+ } ) ;
578+ expect ( computed ) . toStrictEqual ( {
579+ 'deterministic-output-path' : `${ process . env . IEXEC_OUT } /result.json` ,
580+ } ) ;
581+ expect ( files . length ) . toBe ( 2 ) ;
579582 } ) ;
580- expect ( files . length ) . toBe ( 2 ) ;
581- } ) ;
582583
583- it ( 'should send an email successfully and set the callback when requested' , async ( ) => {
584- // protected data setup
585- process . env . IEXEC_DATASET_FILENAME = 'data.zip' ;
586- process . env . IEXEC_REQUESTER_SECRET_1 = JSON . stringify ( {
587- ...JSON . parse ( process . env . IEXEC_REQUESTER_SECRET_1 ) ,
588- useCallback : true ,
589- } ) ;
584+ it ( 'should send an email successfully and set the valid email callback when requested' , async ( ) => {
585+ // protected data setup
586+ process . env . IEXEC_DATASET_FILENAME = 'data.zip' ;
587+ process . env . IEXEC_REQUESTER_SECRET_1 = JSON . stringify ( {
588+ ...JSON . parse ( process . env . IEXEC_REQUESTER_SECRET_1 ) ,
589+ useCallback : true ,
590+ } ) ;
590591
591- await expect ( start ( ) ) . resolves . toBeUndefined ( ) ;
592+ await expect ( start ( ) ) . resolves . toBeUndefined ( ) ;
592593
593- const { result, computed, files } = await readOutputs (
594- process . env . IEXEC_OUT
595- ) ;
596- expect ( result ) . toStrictEqual ( {
597- success : true ,
598- protectedData : process . env . IEXEC_DATASET_FILENAME ,
599- } ) ;
600- expect ( computed ) . toStrictEqual ( {
601- 'deterministic-output-path' : `${ process . env . IEXEC_OUT } /result.json` ,
602- 'callback-data' :
603- '0x0000000000000000000000000000000000000000000000000000000000000001' ,
594+ const { result, computed, files } = await readOutputs (
595+ process . env . IEXEC_OUT
596+ ) ;
597+ expect ( result ) . toStrictEqual ( {
598+ success : true ,
599+ protectedData : process . env . IEXEC_DATASET_FILENAME ,
600+ } ) ;
601+ expect ( computed ) . toStrictEqual ( {
602+ 'deterministic-output-path' : `${ process . env . IEXEC_OUT } /result.json` ,
603+ 'callback-data' :
604+ '0x0000000000000000000000000000000000000000000000000000000000000003' ,
605+ } ) ;
606+ expect ( files . length ) . toBe ( 2 ) ;
604607 } ) ;
605- expect ( files . length ) . toBe ( 2 ) ;
606608 } ) ;
607609
608- it ( 'should output an error if email address does not exist' , async ( ) => {
609- // protected data setup
610- process . env . IEXEC_DATASET_FILENAME = 'dataEmailUserDoesNotExist.zip' ;
610+ describe ( 'with invalid email protectedData' , ( ) => {
611+ it ( 'should output an error if email address does not exist' , async ( ) => {
612+ // protected data setup
613+ process . env . IEXEC_DATASET_FILENAME = 'dataEmailUserDoesNotExist.zip' ;
611614
612- await expect ( start ( ) ) . resolves . toBeUndefined ( ) ;
615+ await expect ( start ( ) ) . resolves . toBeUndefined ( ) ;
613616
614- const { result, computed, files } = await readOutputs (
615- process . env . IEXEC_OUT
616- ) ;
617- expect ( result ) . toStrictEqual ( {
618- success : false ,
619- protectedData : process . env . IEXEC_DATASET_FILENAME ,
620- error : 'The protected email address seems to be invalid.' ,
621- } ) ;
622- expect ( computed ) . toStrictEqual ( {
623- 'deterministic-output-path' : `${ process . env . IEXEC_OUT } /result.json` ,
617+ const { result, computed, files } = await readOutputs (
618+ process . env . IEXEC_OUT
619+ ) ;
620+ expect ( result ) . toStrictEqual ( {
621+ success : false ,
622+ protectedData : process . env . IEXEC_DATASET_FILENAME ,
623+ error : 'The protected email address seems to be invalid.' ,
624+ } ) ;
625+ expect ( computed ) . toStrictEqual ( {
626+ 'deterministic-output-path' : `${ process . env . IEXEC_OUT } /result.json` ,
627+ } ) ;
628+ expect ( files . length ) . toBe ( 2 ) ;
624629 } ) ;
625- expect ( files . length ) . toBe ( 2 ) ;
626- } ) ;
627630
628- it ( 'should output an error if email address is disposable' , async ( ) => {
629- // protected data setup
630- process . env . IEXEC_DATASET_FILENAME = 'dataDisposableEmail.zip' ;
631+ it ( 'should output an error if email address is disposable' , async ( ) => {
632+ // protected data setup
633+ process . env . IEXEC_DATASET_FILENAME = 'dataDisposableEmail.zip' ;
631634
632- await expect ( start ( ) ) . resolves . toBeUndefined ( ) ;
635+ await expect ( start ( ) ) . resolves . toBeUndefined ( ) ;
633636
634- const { result, computed, files } = await readOutputs (
635- process . env . IEXEC_OUT
636- ) ;
637- expect ( result ) . toStrictEqual ( {
638- success : false ,
639- protectedData : process . env . IEXEC_DATASET_FILENAME ,
640- error : 'The protected email address seems to be invalid.' ,
637+ const { result, computed, files } = await readOutputs (
638+ process . env . IEXEC_OUT
639+ ) ;
640+ expect ( result ) . toStrictEqual ( {
641+ success : false ,
642+ protectedData : process . env . IEXEC_DATASET_FILENAME ,
643+ error : 'The protected email address seems to be invalid.' ,
644+ } ) ;
645+ expect ( computed ) . toStrictEqual ( {
646+ 'deterministic-output-path' : `${ process . env . IEXEC_OUT } /result.json` ,
647+ } ) ;
648+ expect ( files . length ) . toBe ( 2 ) ;
641649 } ) ;
642- expect ( computed ) . toStrictEqual ( {
643- 'deterministic-output-path' : `${ process . env . IEXEC_OUT } /result.json` ,
650+
651+ it ( 'should set the invalid email callback when requested' , async ( ) => {
652+ // protected data setup
653+ process . env . IEXEC_DATASET_FILENAME = 'dataEmailUserDoesNotExist.zip' ;
654+
655+ await expect ( start ( ) ) . resolves . toBeUndefined ( ) ;
656+
657+ const { result, computed, files } = await readOutputs (
658+ process . env . IEXEC_OUT
659+ ) ;
660+ expect ( result ) . toStrictEqual ( {
661+ success : false ,
662+ protectedData : process . env . IEXEC_DATASET_FILENAME ,
663+ error : 'The protected email address seems to be invalid.' ,
664+ } ) ;
665+ expect ( computed ) . toStrictEqual ( {
666+ 'deterministic-output-path' : `${ process . env . IEXEC_OUT } /result.json` ,
667+ 'callback-data' :
668+ '0x0000000000000000000000000000000000000000000000000000000000000002' ,
669+ } ) ;
670+ expect ( files . length ) . toBe ( 2 ) ;
644671 } ) ;
645- expect ( files . length ) . toBe ( 2 ) ;
646672 } ) ;
647673 } ) ;
648674 }
0 commit comments