keycloak-scim/src/components/data-loader/__tests__/DataLoader.test.tsx
Erik Jan de Wit dba53a01b3
update who am i on realm create as we need the accessTypes (#276)
* whoAmI has the realm access information
so when a new realm is created the whoAmI request has to be done again

* fixed "add realm" button

* remove debug

* refactor

* also force token update

* refresh realm list on realm change
2021-01-12 07:39:37 -05:00

36 lines
877 B
TypeScript

import React from "react";
import { DataLoader } from "../DataLoader";
import { act } from "@testing-library/react";
import { render, unmountComponentAtNode } from "react-dom";
let container: HTMLDivElement;
beforeEach(() => {
container = document.createElement("div");
document.body.appendChild(container);
});
afterEach(() => {
unmountComponentAtNode(container);
container.remove();
});
describe("<DataLoader />", () => {
it("render", async () => {
const loader = () => Promise.resolve(["a", "b"]);
await act(async () => {
render(
<DataLoader loader={loader}>
{(result) => (
<div>
{result.map((d, i) => (
<i key={i}>{d}</i>
))}
</div>
)}
</DataLoader>,
container
);
});
expect(container.textContent).toBe("ab");
});
});