frigate/web/src/api/__tests__/index.test.jsx

24 lines
609 B
React
Raw Normal View History

2021-02-11 18:13:21 +03:00
import { h } from 'preact';
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', () => {
beforeEach(() => {
vi.spyOn(WS, 'WsProvider').mockImplementation(({ children }) => children);
});
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
});
});