@@ -201,37 +201,22 @@ describe('Mocked API tests', () => {
201201 const errorString = await promise . catch ( inspect )
202202 expect ( typeof errorString === 'string' ) . toBeTruthy ( )
203203 // console.log(inspect(errorString))
204- expect ( inspect ( errorString ) . split ( '\n' ) ) . toEqual ( [
205- expect . stringMatching (
206- 'API error \\(HTTP 400\\) INVALID_FILE_META_DATA: Invalid file metadata https://api2-oltu.transloadit.com/assemblies/foo' ,
207- ) ,
208- expect . stringMatching ( ' at .+' ) ,
209- expect . stringMatching ( ' at .+' ) ,
210- expect . stringMatching (
211- ' at createAssemblyAndUpload \\(.+\\/src\\/Transloadit\\.ts:\\d+:\\d+\\)' ,
212- ) ,
213- expect . stringMatching ( ' at .+\\/test\\/unit\\/mock-http\\.test\\.ts:\\d+:\\d+' ) ,
214- expect . stringMatching ( ' at .+' ) ,
215- expect . stringMatching ( ` code: 'INVALID_FILE_META_DATA',` ) ,
216- expect . stringMatching ( ` rawMessage: 'Invalid file metadata',` ) ,
217- expect . stringMatching ( ' reason: undefined,' ) ,
218- expect . stringMatching (
219- ` assemblySslUrl: 'https:\\/\\/api2-oltu\\.transloadit\\.com\\/assemblies\\/foo'` ,
220- ) ,
221- expect . stringMatching ( ` assemblyId: '123',` ) ,
222- expect . stringMatching ( ' cause: HTTPError: Response code 400 \\(Bad Request\\)' ) ,
223- expect . stringMatching ( ' at .+' ) ,
224- expect . stringMatching ( ' at .+' ) ,
225- expect . stringMatching ( ' at .+' ) ,
226- expect . stringMatching ( ' at .+' ) ,
227- expect . stringMatching ( ' at .+' ) ,
228- expect . stringMatching ( ' at .+' ) ,
229- expect . stringMatching ( ' input: undefined,' ) ,
230- expect . stringMatching ( ` code: 'ERR_NON_2XX_3XX_RESPONSE',` ) ,
231- expect . stringMatching ( ' \\[cause\\]: {}' ) ,
232- expect . stringMatching ( ' }' ) ,
233- expect . stringMatching ( '}' ) ,
234- ] )
204+ const lines = String ( errorString ) . split ( '\n' )
205+ const expectations = [
206+ 'API error \\(HTTP 400\\) INVALID_FILE_META_DATA: Invalid file metadata https://api2-oltu.transloadit.com/assemblies/foo' ,
207+ ` code: 'INVALID_FILE_META_DATA',` ,
208+ ` rawMessage: 'Invalid file metadata',` ,
209+ ' reason: undefined,' ,
210+ ` assemblySslUrl: 'https:\\/\\/api2-oltu\\.transloadit\\.com\\/assemblies\\/foo'` ,
211+ ` assemblyId: '123',` ,
212+ ' cause: HTTPError: Response code 400 \\(Bad Request\\)' ,
213+ ` code: 'ERR_NON_2XX_3XX_RESPONSE',` ,
214+ ' \\[cause\\]: {}' ,
215+ ]
216+
217+ for ( const expectation of expectations ) {
218+ expect ( lines ) . toEqual ( expect . arrayContaining ( [ expect . stringMatching ( expectation ) ] ) )
219+ }
235220 } )
236221
237222 it ( 'should retry correctly on RATE_LIMIT_REACHED' , async ( ) => {
0 commit comments