From 7d3529ebd9e9f06998b02d5995bea0d5dbb5ef91 Mon Sep 17 00:00:00 2001 From: Dominick J Monaco <93451889+HoldUpFjord@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:00:23 -0400 Subject: [PATCH 1/2] Dominick/ Closes #613 Add unit test for component (#618) Added a unit test to verify that the title prop in `AlertTitle.tsx` renders correctly when passed as a string. --------- Co-authored-by: Shashi Lo <362527+shashilo@users.noreply.github.com> --- components/AlertTItle/AlertTitle.test.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 components/AlertTItle/AlertTitle.test.tsx diff --git a/components/AlertTItle/AlertTitle.test.tsx b/components/AlertTItle/AlertTitle.test.tsx new file mode 100644 index 00000000..32010c72 --- /dev/null +++ b/components/AlertTItle/AlertTitle.test.tsx @@ -0,0 +1,10 @@ +import React from 'react'; +import { render } from '@testing-library/react'; +import { AlertTitle } from './AlertTitle'; + +describe('AlertTitle', () => { + it('renders the title text', () => { + const { getByText } = render(); + expect(getByText('Test Title')).toBeInTheDocument(); + }); +}); From 96d46791f5eb5a101315f48c92d8cf86e5930cc0 Mon Sep 17 00:00:00 2001 From: Cody Epstein Date: Wed, 30 Oct 2024 12:04:29 -0700 Subject: [PATCH 2/2] Cody/fix getUserLeagues function (#647) Closes #484 Appwrite returns an array with an empty string if the user is not in any leagues - changed the check to account for this - modified the test for getUserLeagues --- utils/utils.test.ts | 4 ++-- utils/utils.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/utils.test.ts b/utils/utils.test.ts index 1c471924..c1633b16 100644 --- a/utils/utils.test.ts +++ b/utils/utils.test.ts @@ -207,14 +207,14 @@ describe('utils', () => { }); }); - xdescribe('getUserLeagues', () => { + describe('getUserLeagues', () => { it('should return the list of leagues the user is a part of', async () => { (getCurrentLeague as jest.Mock).mockResolvedValue(mockLeague); const result = await getUserLeagues(mockUserData.leagues); expect(result).toStrictEqual([mockLeague]); }); it('should return an empty array if the user has no leagues', async () => { - const result = await getUserLeagues([]); + const result = await getUserLeagues(['']); expect(getCurrentLeague).toHaveBeenCalledTimes(0); expect(result).toStrictEqual([]); }); diff --git a/utils/utils.ts b/utils/utils.ts index ca28a1da..9ff84691 100644 --- a/utils/utils.ts +++ b/utils/utils.ts @@ -127,7 +127,7 @@ export const parseUserPick = ( export const getUserLeagues = async ( leagues: IUser['leagues'], ): Promise => { - if (!leagues || leagues.length === 0) { + if (!leagues || leagues[0] === '') { return []; } const userLeagues = leagues.map((league) => {