Skip to content

Commit

Permalink
fix ui
Browse files Browse the repository at this point in the history
  • Loading branch information
cglotr committed May 15, 2024
1 parent 7f8bd86 commit 14cdc43
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 49 deletions.
8 changes: 4 additions & 4 deletions __tests__/components/app_nav.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ describe('AppNav', () => {
</AuthContext.Provider>
)

const koranNav = await screen.findByText('Koran')
const koranNav = await screen.findByText('koran')

expect(koranNav).toBeInTheDocument()
expect(await userEvent.click(koranNav))
expect(pushMock).toBeCalledWith('/')

const bookmarkNav = await screen.findByText('Bookmark')
const bookmarkNav = await screen.findByText('bookmark')

expect(bookmarkNav).toBeInTheDocument()
expect(await userEvent.click(bookmarkNav))
Expand Down Expand Up @@ -79,13 +79,13 @@ describe('AppNav', () => {
</AuthContext.Provider>
)

const koranNav = await screen.findByText('Koran')
const koranNav = await screen.findByText('koran')

expect(koranNav).toBeInTheDocument()
expect(await userEvent.click(koranNav))
expect(pushMock).toBeCalledWith('/')

const bookmarkNav = await screen.findByText('Bookmark')
const bookmarkNav = await screen.findByText('bookmark')

expect(bookmarkNav).toBeInTheDocument()
expect(await userEvent.click(bookmarkNav))
Expand Down
2 changes: 1 addition & 1 deletion __tests__/components/login_button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('LoginButton', () => {
</AuthContext.Provider>
)

const loginButton = screen.getByText('Login')
const loginButton = screen.getByText('login')
expect(loginButton).toBeInTheDocument()

await userEvent.click(loginButton)
Expand Down
6 changes: 3 additions & 3 deletions __tests__/pages/app.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ describe("App", () => {
render(
<App />
)
expect(screen.getByText("Koran")).toBeInTheDocument()
expect(screen.getByText("Bookmark")).toBeInTheDocument()
expect(screen.getByText("Login")).toBeInTheDocument()
expect(screen.getByText("koran")).toBeInTheDocument()
expect(screen.getByText("bookmark")).toBeInTheDocument()
expect(screen.getByText("login")).toBeInTheDocument()
})
})
2 changes: 1 addition & 1 deletion __tests__/pages/bookmark.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe("BookmarkPage", () => {
expect(await screen.findByText("1:1:verse")).toBeInTheDocument()
expect(await screen.findByText("1:1:translation")).toBeInTheDocument()

const nextButton = await screen.findByText("Next")
const nextButton = await screen.findByText("next")
await userEvent.click(nextButton)

expect(await screen.findByText("1:2")).toBeInTheDocument()
Expand Down
16 changes: 8 additions & 8 deletions __tests__/pages/favs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ describe('FavsPage', () => {
)
})

expect(await screen.findByText("hide verse")).toBeInTheDocument()
expect(await screen.findByText("hide translation")).toBeInTheDocument()
expect(await screen.findByText("📖")).toBeInTheDocument()
expect(await screen.findByText("☪️")).toBeInTheDocument()

expect(await screen.findByText("1:1")).toBeInTheDocument()
expect(await screen.findByText("verse 1:1")).toBeInTheDocument()
Expand All @@ -84,18 +84,18 @@ describe('FavsPage', () => {
expect(await screen.findByText("translation 1:2")).toBeInTheDocument()

await act(async () => {
await userEvent.click(await screen.findByText("hide verse"))
await userEvent.click(await screen.findByText("📖"))
})

expect(screen.queryByText("verse 1:1")).not.toBeInTheDocument()
expect(screen.queryByText("verse 1:2")).not.toBeInTheDocument()
expect(screen.queryByText("☪️ 1:1")).not.toBeInTheDocument()
expect(screen.queryByText("☪️ 1:2")).not.toBeInTheDocument()

await act(async () => {
await userEvent.click(await screen.findByText("hide translation"))
await userEvent.click(await screen.findByText("☪️"))
})

expect(screen.queryByText("translation 1:1")).not.toBeInTheDocument()
expect(screen.queryByText("translation 1:2")).not.toBeInTheDocument()
expect(screen.queryByText("📖 1:1")).not.toBeInTheDocument()
expect(screen.queryByText("📖 1:2")).not.toBeInTheDocument()

await act(async () => {
await userEvent.click(await screen.findByText("1:1"))
Expand Down
2 changes: 1 addition & 1 deletion __tests__/pages/profile.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('ProfilePage', () => {
expect(await screen.findByText('Amir')).toBeInTheDocument()
expect(await screen.findByText('[email protected]')).toBeInTheDocument()

const logoutButton = await screen.findByText('Logout')
const logoutButton = await screen.findByText('logout')
expect(logoutButton).toBeInTheDocument()

await userEvent.click(logoutButton)
Expand Down
2 changes: 1 addition & 1 deletion __tests__/pages/surahs/[id].test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('SurahPage', () => {
</AuthContext.Provider>
)

await userEvent.click((await screen.findAllByText('favorite'))[0])
await userEvent.click((await screen.findAllByText('🩶'))[0])
await userEvent.click((await screen.findAllByText('❤️'))[0])
})
})
2 changes: 1 addition & 1 deletion src/components/login_button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const LoginButton = () => {

const Login = () => {
return (
<Button onClick={googleLogin}>Login</Button>
<Button onClick={googleLogin}>login</Button>
)
}

Expand Down
5 changes: 3 additions & 2 deletions src/components/show_hide_button.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Button } from "./button"

export const ShowHideButton = (props: {
what: string
show: string
hide: string
isHiding: boolean
onClick: () => void
}) => {
return (
<Button
onClick={props.onClick}
>
{props.isHiding ? "show" : "hide"}&nbsp;{props.what}
{props.isHiding ? props.show : props.hide}
</Button>
)
}
6 changes: 4 additions & 2 deletions src/pages/favs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ export default function FavsPage() {
const renderShowHideVerse = () => {
return (
<ShowHideButton
what="verse"
show='🛐'
hide='☪️'
isHiding={favSettings.hideVerse}
onClick={() => {
updateFavSettings({
Expand All @@ -103,7 +104,8 @@ export default function FavsPage() {
const renderShowHideTranslation = () => {
return (
<ShowHideButton
what="translation"
show="📕"
hide="📖"
isHiding={favSettings.hideTranslation}
onClick={() => {
updateFavSettings({
Expand Down
32 changes: 7 additions & 25 deletions src/pages/surahs/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,16 @@ export default function SurahPage(props: { surah: Surah }) {
textDecoration: isFav ? undefined : "underline"
}}
>
{!favSet.has(surahVerse) ? "favorite" : <div style={{ fontSize: `${FONT.FONT_SIZE_S}` }}>❤️</div>}
{!favSet.has(surahVerse) ? "🩶" : "❤️"}
</Button>
)
}

const renderShowHideVerse = () => {
return (
<ShowHideButton
what="verse"
show='🛐'
hide='☪️'
isHiding={surahSettings.hideVerse}
onClick={() => {
updateSurahSettings({
Expand All @@ -78,7 +79,8 @@ export default function SurahPage(props: { surah: Surah }) {
const renderShowHideTranslation = () => {
return (
<ShowHideButton
what="translation"
show="📕"
hide="📖"
isHiding={surahSettings.hideTranslation}
onClick={() => {
updateSurahSettings({
Expand Down Expand Up @@ -128,6 +130,8 @@ export default function SurahPage(props: { surah: Surah }) {
{`${props.surah.surahId}:${verse.verseId}`}
</div>
<div>
{renderShowHideVerse()}
{renderShowHideTranslation()}
{
authContext.isLoggedIn() ?
renderFav(`${props.surah.surahId}:${verse.verseId}`)
Expand Down Expand Up @@ -190,27 +194,6 @@ export default function SurahPage(props: { surah: Surah }) {
)
}

const renderUserActions = () => {
return (
<div
style={{
fontSize: FONT.FONT_SIZE_S,
}}
>
<div
style={{
display: "flex",
justifyContent: "flex-end"
}}
>
{renderShowHideVerse()}
{renderShowHideTranslation()}
</div>
<Break />
</div>
)
}

return (
<>
<Head>
Expand All @@ -223,7 +206,6 @@ export default function SurahPage(props: { surah: Surah }) {
paddingRight: `${DIMENSIONS.SZ_6}px`
}}
>
{renderUserActions()}
{renderVerses()}
</div>
</>
Expand Down

0 comments on commit 14cdc43

Please sign in to comment.