Skip to content
Snippets Groups Projects

CE-2065: convert useIoc to common

Merged CE-2065: convert useIoc to common
All threads resolved!
Merged Christina Jenks requested to merge CE-2065-convert-useioc into develop
All threads resolved!
7 files
+ 80
54
Compare changes
  • Side-by-side
  • Inline
Files
7
import React from "react";
import { act, render, screen } from "@testing-library/react";
import { SnackbarProvider } from "notistack";
import { APIProvider, useIOCList } from "../api/SwaggerApi";
function APIHarness({ children }) {
// We need a snackbar provider at the moment
return (
<SnackbarProvider>
<APIProvider>{children}</APIProvider>
</SnackbarProvider>
);
}
// This component will just try to use a hook from our API
// We want to check that we can get a response from the mock backend
function DisplayIOCs() {
const [iocs] = useIOCList();
return JSON.stringify(iocs);
}
test("that using OpenAPIBackend and MSW works with Swagger-Client and our API hooks", async () => {
// render and wait for the state changes
await act(async () => {
render(
<APIHarness>
<DisplayIOCs />
</APIHarness>
);
});
// check that we got the example IOCList from the OpenAPI spec back
expect(await screen.findByText(/activeDeployment/i)).toBeInTheDocument();
});
Loading