fix tests

This commit is contained in:
Blake Blackshear 2022-05-20 09:27:21 -05:00
parent d8d410802f
commit 3e7ed982d4
4 changed files with 6 additions and 6 deletions

View File

@ -2,7 +2,7 @@ import { rest } from 'msw';
import { API_HOST } from '../src/env'; import { API_HOST } from '../src/env';
export const handlers = [ export const handlers = [
rest.get(`${API_HOST}/api/config`, (req, res, ctx) => { rest.get(`${API_HOST}api/config`, (req, res, ctx) => {
return res( return res(
ctx.status(200), ctx.status(200),
ctx.json({ ctx.json({
@ -35,7 +35,7 @@ export const handlers = [
}) })
); );
}), }),
rest.get(`${API_HOST}/api/stats`, (req, res, ctx) => { rest.get(`${API_HOST}api/stats`, (req, res, ctx) => {
return res( return res(
ctx.status(200), ctx.status(200),
ctx.json({ ctx.json({
@ -54,7 +54,7 @@ export const handlers = [
}) })
); );
}), }),
rest.get(`${API_HOST}/api/events`, (req, res, ctx) => { rest.get(`${API_HOST}api/events`, (req, res, ctx) => {
return res( return res(
ctx.status(200), ctx.status(200),
ctx.json( ctx.json(

View File

@ -1,2 +1,2 @@
export const ENV = 'test'; export const ENV = 'test';
export const API_HOST = 'http://base-url.local:5000'; export const API_HOST = 'http://base-url.local:5000/';

View File

@ -18,6 +18,6 @@ describe('useApiHost', () => {
<Test /> <Test />
</ApiProvider> </ApiProvider>
); );
expect(screen.queryByText('http://base-url.local:5000')).toBeInTheDocument(); expect(screen.queryByText('http://base-url.local:5000/')).toBeInTheDocument();
}); });
}); });

View File

@ -1,2 +1,2 @@
export const ENV = import.meta.env.MODE; export const ENV = import.meta.env.MODE;
export const API_HOST = ENV === "production" ? "" : "http://localhost:5000"; export const API_HOST = ENV === 'production' ? '' : 'http://localhost:5000/';