Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions src/features/pets/components/pet-card/PetCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ describe(PetCard.name, () => {
expect(screen.queryAllByTestId("pet-tag")).toHaveLength(0)
})

it("should display exactly 5 tags", () => {
const tags = ["vacinado", "treinado", "amigável", "tímido", "sociável"]
it("should display exactly 4 tags", () => {
const tags = ["vacinado", "treinado", "amigável", "tímido"]
const pet = { ...petResponseMock, tags }
renderWithProviders(<PetCard pet={pet} />)

Expand All @@ -37,19 +37,12 @@ describe(PetCard.name, () => {
expect(screen.queryByText("...")).not.toBeInTheDocument()
})

it("should display ellipsis when more than 5 tags", () => {
const tags = [
"vacinado",
"treinado",
"amigável",
"tímido",
"sociável",
"castrado",
]
it("should display ellipsis when more than 4 tags", () => {
const tags = ["vacinado", "treinado", "amigável", "tímido", "sociável"]
const pet = { ...petResponseMock, tags }
render(<PetCard pet={pet} />)

tags.slice(0, 5).forEach((tag) => {
tags.slice(0, 4).forEach((tag) => {
expect(screen.getByText(tag)).toBeInTheDocument()
})
expect(screen.getByText("...")).toBeInTheDocument()
Expand Down
14 changes: 7 additions & 7 deletions src/features/pets/components/pet-card/PetCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ export function PetCard({ pet }: PetCardProps) {
return (
<ContainerLayout
key={pet.id}
className="flex flex-col gap-4 px-3 py-4 duration-100 hover:border-2 hover:border-primary"
className="flex flex-col gap-1 px-3 py-4 duration-100 hover:border-2 hover:border-primary"
>
<div className="flex h-40 items-center justify-center rounded-lg border-2 border-dashed border-gray-300 bg-gray-200">
<div className="mb-2 flex h-40 items-center justify-center rounded-lg border-2 border-dashed border-gray-300 bg-gray-200">
<PawPrint size={65} className="text-gray-300" />
</div>

<div className="flex flex-col gap-0.5">
<div className="mb-3 flex flex-col gap-0.5">
<div className="flex items-start justify-between">
<h3 className="text-xl font-bold text-gray-800">{pet.name}</h3>
<PetStatusBadge status={pet.status} />
</div>
<p className="text-sm text-gray-500 italic">{pet.specieName}</p>
<p className="text-2xlg text-gray-500 italic">{pet.species}</p>
</div>

<div className="flex h-10 flex-wrap items-start gap-x-2 gap-y-2">
{pet.tags.slice(0, 5).map((tag) => (
<div className="flex h-15 flex-wrap items-start gap-x-2 gap-y-2 overflow-hidden text-ellipsis whitespace-nowrap">
{pet.tags.slice(0, 4).map((tag) => (
<span
data-testid="pet-tag"
key={tag}
Expand All @@ -35,7 +35,7 @@ export function PetCard({ pet }: PetCardProps) {
{tag}
</span>
))}
{pet.tags.length > 5 && (
{pet.tags.length > 4 && (
<span className="text-xs font-bold text-gray-400">...</span>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/features/pets/types/pets.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PetStatus } from "../enums/pet-status.enum"
export interface Pet {
id: string
name: string
specieName: string
species: string
status: PetStatus
tags: string[]
}
2 changes: 1 addition & 1 deletion src/shared/test-utils/mocks/pets-mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const petMock: PetSchema = {
export const petResponseMock: Pet = {
id: "d8906906-5136-4ce5-825a-73ee95a267a1",
name: "Rex",
specieName: "Cachorro",
species: "Cachorro",
status: PetStatus.AVAILABLE,
tags: ["vacinado", "treinado"],
}
Expand Down
Loading