From a0f88b74fa4ffa0e7a30cde2d669bfc495e395ef Mon Sep 17 00:00:00 2001 From: Anssi Juvonen Date: Wed, 16 Oct 2024 16:00:52 +0300 Subject: [PATCH] Test favorites more thoroughly --- .../__tests__/activityStore.spec.ts | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/components/__tests__/activityStore.spec.ts b/src/components/__tests__/activityStore.spec.ts index 5743d39..004f4bf 100644 --- a/src/components/__tests__/activityStore.spec.ts +++ b/src/components/__tests__/activityStore.spec.ts @@ -220,26 +220,30 @@ describe('activityStore', () => { expect(activityStore.favorites).toEqual(['cucumber']); }); - it('returns only ten favorites', () => { - activityStore.startDate = lastWeek; + it('returns only ten most common favorites', () => { + const expected = [ + 'wheat', + 'rye', + 'rice', + 'apple', + 'raspberry', + 'cucumber', + 'tomato', + 'onion', + 'garlic', + 'endive', + ]; + activityStore.startDate = twoWeeksAgo; + activityStore.weeks.push({ + veggies: [...expected, 'lettuce', 'broccoli', 'lychee'], + startDate: twoWeeksAgo, + }); activityStore.weeks.push({ - veggies: [ - 'wheat', - 'rye', - 'rice', - 'apple', - 'raspberry', - 'cucumber', - 'tomato', - 'onion', - 'garlic', - 'endive', - 'lettuce', - ], + veggies: [...expected, 'lettuce', 'barley'], startDate: lastWeek, }); - expect(activityStore.favorites).toHaveLength(10); + expect(activityStore.favorites).toEqual(expected); }); it('returns unique veggies', () => {