2021-02-11 18:13:21 +03:00
|
|
|
import { h } from 'preact';
|
2021-02-18 07:53:57 +03:00
|
|
|
import * as Mqtt from '../mqtt';
|
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(() => {
|
|
|
|
|
jest.spyOn(Mqtt, 'MqttProvider').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>
|
|
|
|
|
);
|
|
|
|
|
expect(screen.queryByText('http://base-url.local:5000')).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|