Skip to content

Commit

Permalink
finish childrenstore test
Browse files Browse the repository at this point in the history
  • Loading branch information
MaHaWo committed Aug 28, 2024
1 parent 315107d commit 9d97258
Showing 1 changed file with 47 additions and 3 deletions.
50 changes: 47 additions & 3 deletions src/lib/stores/childrenStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import {
addChildObservation,
children,
fetchChildData,
fetchChildrenDataforUser,
fetchObservationData,
fetchObservationDataForUser,
removeChildData,
type ChildObject,
type ChildrenList,
Expand Down Expand Up @@ -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');
}
});
});

0 comments on commit 9d97258

Please sign in to comment.