diff --git a/src/models/club-member.spec.ts b/src/models/club-member.spec.ts index 3cc552c..505624a 100644 --- a/src/models/club-member.spec.ts +++ b/src/models/club-member.spec.ts @@ -26,10 +26,15 @@ describe("ClubMember", () => { test("get dinnerPreferredDateTimeList", () => { // given - const member = generateMockClubMemberBy("lunch-dinner"); + const a = generateMockClubMemberBy("lunch-dinner"); + const b = generateMockClubMemberBy("lunch-dinner"); + + // when + b.dinnerPreferredDateTime = ""; // then - expect(member.dinnerPreferredDateTimeList).toBeInstanceOf(Array); + expect(a.dinnerPreferredDateTimeList).toBeInstanceOf(Array); + expect(b.dinnerPreferredDateTimeList).toEqual([]); }); test("isEligibleForLunch", () => { diff --git a/src/models/club-member.ts b/src/models/club-member.ts index 195e971..6b02e00 100644 --- a/src/models/club-member.ts +++ b/src/models/club-member.ts @@ -15,6 +15,10 @@ export default class ClubMember { ) {} get dinnerPreferredDateTimeList(): string[] { + if (!this.dinnerPreferredDateTime.trim()) { + return []; + } + return this.dinnerPreferredDateTime.split(", "); }