Skip to content

Commit

Permalink
Merge pull request #309 from CBIIT/fix-AuthCtx-test
Browse files Browse the repository at this point in the history
fix: Random AuthContext test case failing in CI
  • Loading branch information
Alejandro-Vega authored Mar 15, 2024
2 parents d0f3aca + e469d61 commit bd08f3e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/components/Contexts/AuthContext.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,11 @@ describe("AuthContext > AuthProvider Tests", () => {

const screen = render(<TestParent mocks={mocks} />);

await waitFor(() => expect(screen.getByTestId("first-name").textContent).toEqual("The API updated my first name"));

const cachedUser = JSON.parse(localStorage.getItem("userDetails"));
expect(cachedUser.firstName).toEqual("The API updated my first name");
await waitFor(() => expect(screen.getByTestId("first-name").textContent).toEqual(mocks[0].result.data.getMyUser.firstName));
await waitFor(() => {
const cachedUser = JSON.parse(localStorage.getItem("userDetails"));
expect(cachedUser.firstName).toEqual(mocks[0].result.data.getMyUser.firstName);
}, { timeout: 1000 });
});

it("should logout the user if the BE API call fails", async () => {
Expand Down

0 comments on commit bd08f3e

Please sign in to comment.