@@ -123,4 +123,69 @@ describe('DataverseInfoRepository', () => {
123123 expect ( error ) . toBeInstanceOf ( Error )
124124 } )
125125 } )
126+
127+ describe ( 'getApplicationTermsOfUse' , ( ) => {
128+ test ( 'should return terms of use on successful response' , async ( ) => {
129+ const testTermsOfUse = 'Be excellent to each other.'
130+ const testSuccessfulResponse = {
131+ data : {
132+ status : 'OK' ,
133+ data : {
134+ message : testTermsOfUse
135+ }
136+ }
137+ }
138+ jest . spyOn ( axios , 'get' ) . mockResolvedValue ( testSuccessfulResponse )
139+
140+ const actual = await sut . getApplicationTermsOfUse ( )
141+
142+ expect ( axios . get ) . toHaveBeenCalledWith (
143+ `${ TestConstants . TEST_API_URL } /info/applicationTermsOfUse` ,
144+ TestConstants . TEST_EXPECTED_UNAUTHENTICATED_REQUEST_CONFIG
145+ )
146+ expect ( actual ) . toMatch ( testTermsOfUse )
147+ } )
148+
149+ test ( 'should return terms of use on successful response with lang' , async ( ) => {
150+ const testLang = 'en'
151+ const testTermsOfUse = 'Be excellent to each other.'
152+ const testSuccessfulResponse = {
153+ data : {
154+ status : 'OK' ,
155+ data : {
156+ message : testTermsOfUse
157+ }
158+ }
159+ }
160+ jest . spyOn ( axios , 'get' ) . mockResolvedValue ( testSuccessfulResponse )
161+
162+ const actual = await sut . getApplicationTermsOfUse ( testLang )
163+
164+ expect ( axios . get ) . toHaveBeenCalledWith (
165+ `${ TestConstants . TEST_API_URL } /info/applicationTermsOfUse` ,
166+ {
167+ params : {
168+ lang : testLang
169+ } ,
170+ headers : {
171+ 'Content-Type' : 'application/json'
172+ }
173+ }
174+ )
175+ expect ( actual ) . toMatch ( testTermsOfUse )
176+ } )
177+
178+ test ( 'should return error result on error response' , async ( ) => {
179+ jest . spyOn ( axios , 'get' ) . mockRejectedValue ( TestConstants . TEST_ERROR_RESPONSE )
180+
181+ let error : ReadError | undefined
182+ await sut . getApplicationTermsOfUse ( ) . catch ( ( e ) => ( error = e ) )
183+
184+ expect ( axios . get ) . toHaveBeenCalledWith (
185+ `${ TestConstants . TEST_API_URL } /info/applicationTermsOfUse` ,
186+ TestConstants . TEST_EXPECTED_UNAUTHENTICATED_REQUEST_CONFIG
187+ )
188+ expect ( error ) . toBeInstanceOf ( Error )
189+ } )
190+ } )
126191} )
0 commit comments