-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added component, lighht and dark mode, and test cases
- Loading branch information
1 parent
bff3dae
commit 9fff103
Showing
3 changed files
with
64 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import LinkTitleCard from '@/app/components/LinkTitleCard'; // Adjust the import path as necessary | ||
|
||
describe('LinkTitleCard', () => { | ||
const title = 'Sample Title'; | ||
const link = '/sample-link'; | ||
const children = <p>Child content</p>; | ||
|
||
it('renders correctly with given props', () => { | ||
render( | ||
<LinkTitleCard title={title} link={link}> | ||
{children} | ||
</LinkTitleCard> | ||
); | ||
|
||
// Check if title is rendered | ||
expect(screen.getByText(title)).toBeInTheDocument(); | ||
|
||
// Check if child content is rendered | ||
expect(screen.getByText('Child content')).toBeInTheDocument(); | ||
|
||
// Check if "Read now" text is rendered | ||
expect(screen.getByText('Read now')).toBeInTheDocument(); | ||
|
||
// Check if the link points to the correct URL | ||
const linkElement = screen.getByRole('link'); | ||
expect(linkElement).toHaveAttribute('href', link); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Link from "next/link"; | ||
import { ChevronArrowSpan } from "@/app/components/ChevronArrow"; | ||
import { ReactNode } from "react"; | ||
|
||
interface LinkTitleCardProps { | ||
title: string; | ||
link: string; | ||
children: ReactNode; | ||
} | ||
|
||
const LinkTitleCard = ({ title, link, children }: LinkTitleCardProps) => { | ||
return ( | ||
<Link | ||
href={link} | ||
key={link} | ||
className="button-arrow group flex flex-col relative group w-full bg-white dark:bg-google-grey p-1 dark:bg-opacity-10 rounded-md overflow-hidden shadow-lg border dark:border-google-black border-b-google-lightGrey transition-all duration-200 hover:shadow-2xl" | ||
> | ||
<div className="bg-google-lightGrey dark:bg-google-black p-4"> | ||
<h5>{title}</h5> | ||
</div> | ||
<div className="p-4 gap-y-4 flex flex-col justify-between h-full"> | ||
{children} | ||
<ChevronArrowSpan>Read now</ChevronArrowSpan> | ||
</div> | ||
</Link> | ||
); | ||
} | ||
|
||
export default LinkTitleCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters