Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudio Benedetti committed Jan 15, 2024
1 parent f5efd1a commit 4adf29a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/utils/__tests__/http-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,26 @@ describe('Rerouting', () => {

})

it('sould support escaping in rerouting rules', async () => {
const customSupport = {
...support,
reroutingRules: [
{from: '^/or\\.ig$', to: '/reroute$1'}
]
}
const client = createFetchHttpClient.bind<() => HttpClientInstance>(customSupport)()

const {origin} = window.location

await client.get('/orrig')
await client.get('/or.ig')

expect(fetchMock).toBeCalledTimes(2)
const defaultConfig = {method: 'GET', headers: {'Content-Type': 'application/json'}}
expect(fetchMock).toHaveBeenNthCalledWith(1, `${origin}/orrig`, defaultConfig)
expect(fetchMock).toHaveBeenNthCalledWith(2, `${origin}/reroute$1`, defaultConfig)
})

it('should be robust to incorrect rerouting rules', async () => {
const empty = {...support, reroutingRules: []}
const incomplete = {...support, reroutingRules: [{}]}
Expand Down

0 comments on commit 4adf29a

Please sign in to comment.