From 9d9725824f9e69ecf26727b12c766d6d5884b3e4 Mon Sep 17 00:00:00 2001 From: Harald Mack Date: Wed, 28 Aug 2024 09:56:07 +0200 Subject: [PATCH] finish childrenstore test --- src/lib/stores/childrenStore.test.ts | 50 ++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 3 deletions(-) diff --git a/src/lib/stores/childrenStore.test.ts b/src/lib/stores/childrenStore.test.ts index e56372db..b85cb491 100644 --- a/src/lib/stores/childrenStore.test.ts +++ b/src/lib/stores/childrenStore.test.ts @@ -5,7 +5,9 @@ import { addChildObservation, children, fetchChildData, + fetchChildrenDataforUser, fetchObservationData, + fetchObservationDataForUser, removeChildData, type ChildObject, type ChildrenList, @@ -158,9 +160,51 @@ describe('normal functionality', () => { } }); - it('should fetch list of childrendata', async () => {}); + it('should fetch list of childrendata', async () => { + children.set(mockChildList); + const data = await fetchChildrenDataforUser('alpha'); + + expect(data).toEqual([ + { + name: 'bar', + age: 5, + nationality: 'german' + }, + { + name: 'foo', + age: 3, + nationality: 'turkish' + } + ]); + }); + + it('should fetch list of observationdata successfully', async () => { + children.set(mockChildList); + const data = await fetchObservationDataForUser('alpha'); + + expect(data).toEqual([ + ['childA', mockObservationData], + ['childB', mockObservationData] + ]); + }); + + it('cannot fetch childrendata from uknown', async () => { + children.set(mockChildList); + + try { + await fetchChildrenDataforUser('x'); + } catch (error: Error | unknown) { + expect((error as Error).message).toBe('No such user in the childrenstore'); + } + }); - it('cannot fetch childrendata from uknown', async () => {}); + it('cannot fetch observationdata from uknown', async () => { + children.set(mockChildList); - it('cannot fetch observationdata from uknown', async () => {}); + try { + fetchObservationDataForUser('x'); + } catch (error: Error | unknown) { + expect((error as Error).message).toBe('No such user in the childrenstore'); + } + }); });