-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
93 additions
and
11 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { get } from 'svelte/store'; | ||
import { describe, expect, it } from 'vitest'; | ||
import { | ||
addContent, | ||
content, | ||
removeContent, | ||
type ChildrenSurvey, | ||
type ContentList, | ||
type RegistrationForm | ||
} from './contentStore'; | ||
|
||
describe('test_normal_functionality', async () => { | ||
const mockChildSurvey: ChildrenSurvey = { | ||
can_do_this: 'incomplete', | ||
can_do_that: 'fully', | ||
can_do_the_other: 'no' | ||
}; | ||
|
||
const mockRegistrationForm: RegistrationForm = { | ||
name: 'Tom', | ||
gender: 'male' | ||
}; | ||
|
||
const mockContentList: ContentList = { | ||
childrenSurveys: { | ||
testsurvey: mockChildSurvey | ||
}, | ||
registrationForms: { | ||
testregistration: mockRegistrationForm | ||
} | ||
}; | ||
|
||
it('should add content successfully when key is not yet there', async () => { | ||
content.set(mockContentList); | ||
|
||
await addContent('childrenSurveys', 'dummySurvey', mockChildSurvey); | ||
await addContent('registrationForms', 'childRegistration', mockRegistrationForm); | ||
|
||
expect(get(content)['childrenSurveys']['dummySurvey']).toEqual(mockChildSurvey); | ||
expect(get(content)['registrationForms']['childRegistration']).toEqual(mockRegistrationForm); | ||
}); | ||
|
||
it('should remove content from the contentstore successfully', async () => { | ||
content.set(mockContentList); | ||
await removeContent('childrenSurveys', 'testsurvey'); | ||
// await removeContent('registrationForms', 'childRegistration'); | ||
|
||
expect(get(content)['childrenSurveys']['testsurvey']).toBeUndefined(); | ||
// expect(get(content)['registrationForms']['childRegistration']).toBeUndefined(); | ||
}); | ||
|
||
// it('throw error when adding an element with an existing key', async () => { | ||
// content.set(mockContentList); | ||
|
||
// try { | ||
// await removeContent('childrenSurveys', 'notthere'); | ||
// } catch (error: Error | unknown) { | ||
// expect((error as Error).message).toBe('No such key in the contentstore'); | ||
// } | ||
// }); | ||
|
||
it('throw error when removing an element with a non-existing key', async () => {}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters