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

24 lines
619 B
React
Raw Normal View History

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