Skip to content

Commit

Permalink
fix: fix undefined favorite item list (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyphilia authored Sep 8, 2022
1 parent 25f09c2 commit 6cd4f07
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions cypress/integration/item/favorite/favoriteItem.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
buildItemMenuButtonId,
buildItemMenu,
NAVIGATION_ROOT_ID,
FAVORITE_ITEMS_ID,
} from '../../../../src/config/selectors';
import {
buildMemberWithFavorites,
Expand All @@ -25,6 +26,19 @@ const toggleFavoriteButton = (itemId) => {
const favoriteItems = [SAMPLE_ITEMS.items[1].id, SAMPLE_ITEMS.items[2].id];

describe('Favorite Item', () => {
describe('Member has no favorite items', () => {
beforeEach(() => {
cy.setUpApi({
...SAMPLE_ITEMS,
});
cy.visit(FAVORITE_ITEMS_PATH);
});

it('Show empty table', () => {
cy.get(`#${FAVORITE_ITEMS_ID}`).should('exist');
});
});

describe('Member has several valid favorite items', () => {
beforeEach(() => {
cy.setUpApi({
Expand Down
3 changes: 2 additions & 1 deletion src/utils/member.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { validate } from 'uuid';
import { List } from 'immutable';

export const isMemberIdValid = (memberId) => validate(memberId?.trim());

Expand All @@ -7,4 +8,4 @@ export const getMemberById = (members, id) =>

export const getMemberAvatar = (extra) => extra?.avatar;

export const getFavoriteItems = (extra) => extra?.favoriteItems;
export const getFavoriteItems = (extra) => extra?.favoriteItems || List();

0 comments on commit 6cd4f07

Please sign in to comment.