From 45d2a49e22b9c1ee7ee5256d5810d4378219aa40 Mon Sep 17 00:00:00 2001 From: Mischa Spiegelmock Date: Mon, 1 Jul 2024 20:56:53 -0700 Subject: [PATCH] webtest --- web/app/ui/LoginButton.tsx | 17 ++++++++++------- web/lib/component/home/Home.test.tsx | 23 ++++++++++++++--------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/web/app/ui/LoginButton.tsx b/web/app/ui/LoginButton.tsx index e6e718e..abdf5d1 100644 --- a/web/app/ui/LoginButton.tsx +++ b/web/app/ui/LoginButton.tsx @@ -1,12 +1,15 @@ -import { auth } from '@/auth'; -import { authenticate, unauthenticate } from '../actions'; +'use client' + +import { auth } from '@/auth' +import { authenticate, unauthenticate } from '../actions' +import { useSession } from 'next-auth/react' interface Props { - className?: string; + className?: string } -export const Authentication = async ({ className }: Props) => { - const session = await auth(); +export const Authentication = ({ className }: Props) => { + const { data: session } = useSession() return (
@@ -22,5 +25,5 @@ export const Authentication = async ({ className }: Props) => { )}
- ); -}; + ) +} diff --git a/web/lib/component/home/Home.test.tsx b/web/lib/component/home/Home.test.tsx index a8788db..e472f2f 100644 --- a/web/lib/component/home/Home.test.tsx +++ b/web/lib/component/home/Home.test.tsx @@ -1,15 +1,20 @@ -import { render, screen } from '@testing-library/react'; -import Home from './Home'; +import { render, screen } from '@testing-library/react' +import Home from './Home' +import { SessionProvider } from 'next-auth/react' -const DEFAULT_PROPS = {}; +const DEFAULT_PROPS = {} const createComponent = () => { - render(); -}; + render( + + + , + ) +} describe('Home', () => { it('should able to render component', () => { - createComponent(); - expect(screen.getByText('Next+SST')).toBeTruthy(); - }); -}); + createComponent() + expect(screen.getByText('SST Template')).toBeTruthy() + }) +})