Skip to content

Commit

Permalink
fix: tests favorite and rename favorite
Browse files Browse the repository at this point in the history
  • Loading branch information
juliaam committed Sep 9, 2024
1 parent bb9d3a8 commit 83cb4e4
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/pages/home/components/Sidebar/Sidebar.components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import scss from './Sidebar.module.scss';
import { FilteredAccountsProps } from './Sidebar.types';

export function FilteredAccounts(props: FilteredAccountsProps): ReactNode {
const { favoritesAccounts, socialMedias } = useSocialMediaStore();
const { favoriteAccounts, socialMedias } = useSocialMediaStore();

return (
<div className={scss.accordionContainer}>
<SocialAccordion
accounts={favoritesAccounts}
accounts={favoriteAccounts}
error={false}
title="Favorite Accounts"
/>
Expand Down
1 change: 0 additions & 1 deletion src/pages/home/components/Sidebar/Sidebar.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ describe('Sidebar component', () => {
accounts: {
data: {
DISCORD_EXAMPLE_ID: [],
FAVORITE_ACCOUNTS_ID: [],
TWITTER_EXAMPLE_ID: [],
},
error: '',
Expand Down
13 changes: 0 additions & 13 deletions src/stores/__mocks__/useSocialMediaStore.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,6 @@ export const mockedAccounts = vi.fn(() => ({
valid: false,
},
],
FAVORITE_ACCOUNTS_ID: [
{
avatar: 'https://example.com/image2.jpg',
expiresAt: '',
favorite: true,
generatedAt: '',
id: '15',
socialMediaId: 'FAVORITE_ACCOUNTS_ID',
token: 'FAVORITE_EXAMPLE_TOKEN_15',
userName: 'Favorite User 15',
valid: true,
},
],
TWITTER_EXAMPLE_ID: [
{
avatar: 'https://example.com/image2.jpg',
Expand Down
8 changes: 4 additions & 4 deletions src/stores/useSocialMediaStore/useSocialMediaStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ export const useSocialMediaStore = create<SocialMediaState>((set) => ({
};

set((state) => ({
favoritesAccounts: [...state.favoritesAccounts, favoritedAccount],
favoriteAccounts: [...state.favoriteAccounts, favoritedAccount],
}));
}
},

favoritesAccounts: [],
favoriteAccounts: [],

getAllAccounts: async (): Promise<void> => {
set((state) => ({ accounts: { ...state.accounts, loading: true } }));
Expand Down Expand Up @@ -99,7 +99,7 @@ export const useSocialMediaStore = create<SocialMediaState>((set) => ({
fetchedSocialMediasMap.set(socialMedia.id, socialMedia);
}

const favoritesAccounts = fetchedAccounts
const favoriteAccounts = fetchedAccounts
.filter((account) => account.favorite)
.map((account) => ({
...account,
Expand All @@ -112,7 +112,7 @@ export const useSocialMediaStore = create<SocialMediaState>((set) => ({
error: '',
loading: false,
},
favoritesAccounts,
favoriteAccounts,
socialMedias: fetchedSocialMediasMap,
}));
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type SocialMediaState = {
favorite: boolean
) => Promise<void>;

favoritesAccounts: StoreAccount[];
favoriteAccounts: StoreAccount[];

getAllAccounts: () => Promise<void>;

Expand Down

0 comments on commit 83cb4e4

Please sign in to comment.