Fix tests

This commit is contained in:
Nick Mowen 2022-10-24 15:52:18 -06:00
parent 2a2adfaf20
commit c82f5240b6

View File

@ -11,7 +11,7 @@ describe('Camera Route', () => {
beforeEach(() => {
mockSetOptions = jest.fn();
mockUsePersistence = jest.spyOn(Context, 'usePersistence').mockImplementation(() => [{}, mockSetOptions]);
mockUsePersistence = jest.spyOn(Context, 'usePersistence').mockImplementation(() => [{}, mockSetOptions, true]);
jest.spyOn(AutoUpdatingCameraImage, 'default').mockImplementation(({ searchParams }) => {
return <div data-testid="mock-image">{searchParams.toString()}</div>;
});
@ -32,11 +32,12 @@ describe('Camera Route', () => {
regions: false,
},
mockSetOptions,
true,
]);
render(<Camera camera="front" />);
await waitForElementToBeRemoved(() => screen.queryByLabelText('Loading…'));
await waitForElementToBeRemoved(() => screen.queryByLabelText('Loading…'), { timeout: 10 });
fireEvent.click(screen.queryByText('Debug'));
fireEvent.click(screen.queryByText('Show Options'));
@ -47,20 +48,20 @@ describe('Camera Route', () => {
test('updates camera feed options to persistence', async () => {
mockUsePersistence
.mockReturnValueOnce([{}, mockSetOptions])
.mockReturnValueOnce([{}, mockSetOptions])
.mockReturnValueOnce([{}, mockSetOptions])
.mockReturnValueOnce([{}, mockSetOptions])
.mockReturnValueOnce([{}, mockSetOptions])
.mockReturnValueOnce([{}, mockSetOptions])
.mockReturnValueOnce([{}, mockSetOptions])
.mockReturnValueOnce([{}, mockSetOptions])
.mockReturnValueOnce([{ bbox: true }, mockSetOptions])
.mockReturnValueOnce([{ bbox: true, timestamp: true }, mockSetOptions]);
.mockReturnValueOnce([{}, mockSetOptions, true])
.mockReturnValueOnce([{}, mockSetOptions, true])
.mockReturnValueOnce([{}, mockSetOptions, true])
.mockReturnValueOnce([{}, mockSetOptions, true])
.mockReturnValueOnce([{}, mockSetOptions, true])
.mockReturnValueOnce([{}, mockSetOptions, true])
.mockReturnValueOnce([{}, mockSetOptions, true])
.mockReturnValueOnce([{}, mockSetOptions, true])
.mockReturnValueOnce([{ bbox: true }, mockSetOptions, true])
.mockReturnValueOnce([{ bbox: true, timestamp: true }, mockSetOptions, true]);
render(<Camera camera="front" />);
await waitForElementToBeRemoved(() => screen.queryByLabelText('Loading…'));
await waitForElementToBeRemoved(() => screen.queryByLabelText('Loading…'), { timeout: 10 });
fireEvent.click(screen.queryByText('Debug'));
fireEvent.click(screen.queryByText('Show Options'));