-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create reverseProxyCheckerLogic.test.ts
- Loading branch information
1 parent
9abfda6
commit 49d0deb
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
frontend/src/lib/components/ReverseProxyChecker/reverseProxyCheckerLogic.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { expectLogic } from 'kea-test-utils' | ||
|
||
import { useMocks } from '~/mocks/jest' | ||
import { initKeaTests } from '~/test/init' | ||
|
||
import { reverseProxyCheckerLogic } from './reverseProxyCheckerLogic' | ||
|
||
const hasReverseProxyValues = [['https://proxy.example.com'], [null]] | ||
const doesNotHaveReverseProxyValues = [[null], [null]] | ||
|
||
const useMockedValues = (results: { timestamp: string; $lib_custom_api_host?: string }[]): void => { | ||
useMocks({ | ||
post: { | ||
'/api/projects/:team/query': () => [ | ||
200, | ||
{ | ||
results, | ||
}, | ||
], | ||
}, | ||
}) | ||
} | ||
|
||
describe('reverseProxyCheckerLogic', () => { | ||
let logic: ReturnType<typeof reverseProxyCheckerLogic.build> | ||
|
||
beforeEach(() => { | ||
initKeaTests() | ||
localStorage.clear() | ||
logic = reverseProxyCheckerLogic() | ||
}) | ||
|
||
afterEach(() => { | ||
logic.unmount() | ||
}) | ||
|
||
it('should not have a reverse proxy set - when no data', async () => { | ||
useMockedValues([]) | ||
|
||
logic.mount() | ||
await expectLogic(logic).toFinishAllListeners().toMatchValues({ | ||
hasReverseProxy: false, | ||
}) | ||
}) | ||
|
||
it('should not have a reverse proxy set - when data with no lib_custom_api_host values', async () => { | ||
useMockedValues(doesNotHaveReverseProxyValues) | ||
Check failure on line 47 in frontend/src/lib/components/ReverseProxyChecker/reverseProxyCheckerLogic.test.ts GitHub Actions / Code quality checks
|
||
|
||
logic.mount() | ||
await expectLogic(logic).toFinishAllListeners().toMatchValues({ | ||
hasReverseProxy: false, | ||
}) | ||
}) | ||
|
||
it('should have a reverse proxy set', async () => { | ||
useMockedValues(hasReverseProxyValues) | ||
Check failure on line 56 in frontend/src/lib/components/ReverseProxyChecker/reverseProxyCheckerLogic.test.ts GitHub Actions / Code quality checks
|
||
|
||
logic.mount() | ||
await expectLogic(logic).toFinishAllListeners().toMatchValues({ | ||
hasReverseProxy: true, | ||
}) | ||
}) | ||
}) |