2021-02-11 18:13:21 +03:00
|
|
|
import { h } from 'preact';
|
2022-11-24 05:03:20 +03:00
|
|
|
import * as WS from '../ws';
|
2022-03-06 07:16:31 +03:00
|
|
|
import { ApiProvider, useApiHost } from '..';
|
|
|
|
|
import { render, screen } from 'testing-library';
|
2021-02-11 18:13:21 +03:00
|
|
|
|
|
|
|
|
describe('useApiHost', () => {
|
2021-02-18 07:53:57 +03:00
|
|
|
beforeEach(() => {
|
2022-11-24 05:03:20 +03:00
|
|
|
vi.spyOn(WS, 'WsProvider').mockImplementation(({ children }) => children);
|
2021-02-18 07:53:57 +03:00
|
|
|
});
|
|
|
|
|
|
2021-02-11 18:13:21 +03:00
|
|
|
test('is set from the baseUrl', async () => {
|
|
|
|
|
function Test() {
|
|
|
|
|
const apiHost = useApiHost();
|
|
|
|
|
return <div>{apiHost}</div>;
|
|
|
|
|
}
|
|
|
|
|
render(
|
|
|
|
|
<ApiProvider>
|
|
|
|
|
<Test />
|
|
|
|
|
</ApiProvider>
|
|
|
|
|
);
|
2022-05-20 17:27:21 +03:00
|
|
|
expect(screen.queryByText('http://base-url.local:5000/')).toBeInTheDocument();
|
2021-02-11 18:13:21 +03:00
|
|
|
});
|
|
|
|
|
});
|