Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
bduhbya committed Jun 20, 2024
1 parent cb35e75 commit 085f0e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
21 changes: 16 additions & 5 deletions src/app/components/CombatTracker.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import { render, fireEvent, act, waitFor, queryAllByText, getByTestId } from "@testing-library/react";
import {
render,
fireEvent,
act,
waitFor,
queryAllByText,
getByTestId,
} from "@testing-library/react";
import CombatTracker, { activeCharacterTestId } from "./CombatTracker";
import "@testing-library/jest-dom";
import React from "react";
Expand Down Expand Up @@ -119,7 +126,9 @@ describe("CombatTracker", () => {
});

it("moves current active character down correctly", async () => {
const { getByText, queryAllByText, getByTestId } = render(<CombatTracker />);
const { getByText, queryAllByText, getByTestId } = render(
<CombatTracker />,
);
const moveDownButton = getByText(strings.moveDownLabel);
const mockCharacterFiles = [
mockSingleCharacterWarriorFile,
Expand All @@ -140,17 +149,19 @@ describe("CombatTracker", () => {
expect(getByText("Mock InitiativeInputDialog")).toBeInTheDocument(),
);
act(() => handleConfirmHook(addedCharacter));
await waitFor(() =>{
await waitFor(() => {
const characterElements = queryAllByText(addedCharacter.name);
expect(characterElements.length === expectedCharacterCount);
});
const initiativeElements = queryAllByText(addedCharacter.initiative.toString());
const initiativeElements = queryAllByText(
addedCharacter.initiative.toString(),
);
expect(initiativeElements.length === expectedCharacterCount);
}

var activeCharacterRow = getByTestId(`${activeCharacterTestId}0`);
expect(activeCharacterRow).not.toBeNull();
act (() => fireEvent.click(moveDownButton)); // Move the active character down
act(() => fireEvent.click(moveDownButton)); // Move the active character down
await waitFor(() => {
activeCharacterRow = getByTestId(`${activeCharacterTestId}1`);
expect(activeCharacterRow).not.toBeNull();
Expand Down
4 changes: 3 additions & 1 deletion src/app/components/CombatTracker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ const CombatTracker: React.FC = () => {
key={index}
onClick={() => handleCharacterClick(character)}
className={character.active ? "bg-gray-200" : ""}
data-testid={character.active ? `${activeCharacterTestId}${index}` : ""}
data-testid={
character.active ? `${activeCharacterTestId}${index}` : ""
}
>
<td className="border p-2">
{character.active && <CheckmarkIconPositive />}
Expand Down

0 comments on commit 085f0e6

Please sign in to comment.