@@ -77,18 +77,30 @@ describe('DownloadKmsPublicCaLink component tests suite', () => {
7777 const buttons : {
7878 type : CertificateType ;
7979 label : string ;
80+ expectedCa : 'publicCA' | 'publicRsaCA' ;
81+ expectedFilename : string ;
82+ expectedCertificate : string ;
8083 } [ ] = [
8184 {
8285 type : 'publicCaRest' ,
8386 label : 'key_management_service_dashboard_button_label_download_ca' ,
87+ expectedCa : 'publicCA' ,
88+ expectedFilename : 'okms_test-region_public_ca.pem' ,
89+ expectedCertificate : mockCertificates . publicCA ,
8490 } ,
8591 {
8692 type : 'publicCaKmip' ,
8793 label : 'key_management_service_dashboard_button_label_download_ca' ,
94+ expectedCa : 'publicCA' ,
95+ expectedFilename : 'okms_test-region_public_ca.pem' ,
96+ expectedCertificate : mockCertificates . publicCA ,
8897 } ,
8998 {
9099 type : 'publicCaRsaKmip' ,
91100 label : 'key_management_service_dashboard_button_label_download_rsa_ca' ,
101+ expectedCa : 'publicRsaCA' ,
102+ expectedFilename : 'okms_test-region_public_rsa_ca.pem' ,
103+ expectedCertificate : mockCertificates . publicRsaCA ,
92104 } ,
93105 ] ;
94106
@@ -103,26 +115,29 @@ describe('DownloadKmsPublicCaLink component tests suite', () => {
103115 } ,
104116 ) ;
105117
106- test ( 'should download publicCa certificate when clicked' , async ( ) => {
107- const { downloadLink } = await renderComponentAndGetLink ( {
108- type : 'publicCaRest' ,
109- label : 'key_management_service_dashboard_button_label_download_ca' ,
110- } ) ;
118+ test . each ( buttons ) (
119+ 'should download $expectedCa certificate when clicked on $type button' ,
120+ async ( { type, label, expectedFilename, expectedCertificate } ) => {
121+ const { downloadLink } = await renderComponentAndGetLink ( {
122+ type,
123+ label,
124+ } ) ;
111125
112- const user = userEvent . setup ( ) ;
113- await waitFor ( ( ) => user . click ( downloadLink ) ) ;
126+ const user = userEvent . setup ( ) ;
127+ await waitFor ( ( ) => user . click ( downloadLink ) ) ;
114128
115- await waitFor ( ( ) => {
116- expect ( api . getOkmsPublicCa ) . toHaveBeenCalledWith ( mockOkms . id ) ;
117- } ) ;
129+ await waitFor ( ( ) => {
130+ expect ( api . getOkmsPublicCa ) . toHaveBeenCalledWith ( mockOkms . id ) ;
131+ } ) ;
118132
119- await waitFor ( ( ) => {
120- expect ( initiateTextFileDownload ) . toHaveBeenCalledWith ( {
121- text : mockCertificates . publicCA ,
122- filename : 'okms_test-region_public_ca.pem' ,
133+ await waitFor ( ( ) => {
134+ expect ( initiateTextFileDownload ) . toHaveBeenCalledWith ( {
135+ text : expectedCertificate ,
136+ filename : expectedFilename ,
137+ } ) ;
123138 } ) ;
124- } ) ;
125- } ) ;
139+ } ,
140+ ) ;
126141
127142 test ( 'should download publicRsaCa certificate when clicked' , async ( ) => {
128143 const { downloadLink } = await renderComponentAndGetLink ( {
0 commit comments