Skip to content

Commit

Permalink
Add router unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zlwaterfield committed Mar 14, 2024
1 parent 7fa3923 commit ddea077
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/__tests__/utils/request-router.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { defaultConfig } from '../../posthog-core'
import { RequestRouter, RequestRouterTarget } from '../../utils/request-router'

describe('request-router', () => {
Expand Down Expand Up @@ -75,4 +76,16 @@ describe('request-router', () => {
mockPostHog.config.api_host = 'https://eu.posthog.com'
expect(router.endpointFor('api')).toEqual('https://eu.i.posthog.com')
})

it('should check this api_host for a proxy', () => {
const mockPostHog = { config: {} }
const router = new RequestRouter(mockPostHog as any)
expect(router.isUsingProxy()).toEqual(false)

mockPostHog.config['api_host'] = defaultConfig().api_host
expect(router.isUsingProxy()).toEqual(false)

mockPostHog.config['api_host'] = 'https://z.example.com'
expect(router.isUsingProxy()).toEqual(true)
})
})

0 comments on commit ddea077

Please sign in to comment.