generated from mantinedev/vite-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Test population-related components #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e7212a5
test: Tests for HouseholdAdapter
anth-volk 5981d12
test: Tests for household API functions
anth-volk 60767be
test: Add tests for population frames
anth-volk f66586a
test: Tests for population hooks
anth-volk a56c236
test: Test populations page
anth-volk 2f69346
test: Test population reducer
anth-volk 43d36f7
fix: Improve reducer test
anth-volk 1a3167f
test: Tests for HouseholdBuilder
anth-volk 31ad112
test: Add tests for HouseholdQueries
anth-volk 32a454d
test: Tests for HouseholdValidation
anth-volk fd841d2
test: PopulationOps tests
anth-volk 3985f00
test: Add tests for HouseholdBuilder
anth-volk 630f021
test: Fix test fixtures
anth-volk a006e14
fix: Fix for type check
anth-volk f57f8f9
fix: Typing
anth-volk cf55b3a
chore: ESLint
anth-volk 6a1dbaf
chore: Prettier
anth-volk 173667a
test: Fix various tests
anth-volk 38201c6
fix: Fix some failing tests
anth-volk bfb354a
test: Fix failing tests
anth-volk ef26a2a
fix: Use shallowEqual in HouseholdBuilderFrame
anth-volk 4be133a
fix: Fix tests
anth-volk cc2f7e2
chore: Prettier
anth-volk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
153 changes: 153 additions & 0 deletions
153
app/src/tests/fixtures/adapters/HouseholdAdapterMocks.ts
This file contains hidden or 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,153 @@ | ||
import { HouseholdData } from '@/types/ingredients/Household'; | ||
import { HouseholdMetadata } from '@/types/metadata/householdMetadata'; | ||
|
||
export const mockEntityMetadata = { | ||
person: { | ||
key: 'person', | ||
plural: 'people', | ||
label: 'Person', | ||
}, | ||
tax_unit: { | ||
key: 'tax_unit', | ||
plural: 'tax_units', | ||
label: 'Tax unit', | ||
}, | ||
marital_unit: { | ||
key: 'marital_unit', | ||
plural: 'marital_units', | ||
label: 'Marital unit', | ||
}, | ||
household: { | ||
key: 'household', | ||
plural: 'households', | ||
label: 'Household', | ||
}, | ||
spm_unit: { | ||
key: 'spm_unit', | ||
plural: 'spm_units', | ||
label: 'SPM unit', | ||
}, | ||
}; | ||
|
||
export const mockHouseholdMetadata: HouseholdMetadata = { | ||
id: '12345', | ||
country_id: 'us', | ||
household_json: { | ||
people: { | ||
person1: { | ||
age: { 2024: 30 }, | ||
employment_income: { 2024: 50000 }, | ||
}, | ||
person2: { | ||
age: { 2024: 28 }, | ||
employment_income: { 2024: 45000 }, | ||
}, | ||
}, | ||
tax_units: { | ||
tax_unit1: { | ||
members: ['person1', 'person2'], | ||
}, | ||
}, | ||
marital_units: { | ||
marital_unit1: { | ||
members: ['person1', 'person2'], | ||
}, | ||
}, | ||
spm_units: { | ||
spm_unit1: { | ||
members: ['person1', 'person2'], | ||
}, | ||
}, | ||
households: { | ||
household1: { | ||
members: ['person1', 'person2'], | ||
}, | ||
}, | ||
families: { | ||
family1: { | ||
members: ['person1', 'person2'], | ||
}, | ||
}, | ||
}, | ||
api_version: 'v1', | ||
household_hash: '<household_hash>', | ||
}; | ||
|
||
export const mockHouseholdMetadataWithUnknownEntity: HouseholdMetadata = { | ||
id: '67890', | ||
country_id: 'uk', | ||
household_json: { | ||
people: { | ||
person1: { | ||
age: { 2024: 40 }, | ||
}, | ||
}, | ||
// @ts-expect-error | ||
unknown_entity: { | ||
entity1: { | ||
some_property: 'value', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const mockHouseholdData: HouseholdData = { | ||
people: { | ||
person1: { | ||
age: { 2024: 30 }, | ||
employment_income: { 2024: 50000 }, | ||
}, | ||
person2: { | ||
age: { 2024: 28 }, | ||
employment_income: { 2024: 45000 }, | ||
}, | ||
}, | ||
taxUnits: { | ||
tax_unit1: { | ||
members: ['person1', 'person2'], | ||
head: 'person1', | ||
}, | ||
}, | ||
maritalUnits: { | ||
marital_unit1: { | ||
members: ['person1', 'person2'], | ||
}, | ||
}, | ||
}; | ||
|
||
export const mockHouseholdDataWithMultipleEntities: HouseholdData = { | ||
people: { | ||
person1: { age: { 2024: 25 } }, | ||
person2: { age: { 2024: 23 } }, | ||
person3: { age: { 2024: 5 } }, | ||
}, | ||
taxUnits: { | ||
tax_unit1: { | ||
members: ['person1', 'person2', 'person3'], | ||
head: 'person1', | ||
}, | ||
}, | ||
maritalUnits: { | ||
marital_unit1: { | ||
members: ['person1', 'person2'], | ||
}, | ||
}, | ||
spmUnits: { | ||
spm_unit1: { | ||
members: ['person1', 'person2', 'person3'], | ||
}, | ||
}, | ||
}; | ||
|
||
export const mockEmptyHouseholdData: HouseholdData = { | ||
people: {}, | ||
}; | ||
|
||
export const mockHouseholdDataWithUnknownEntity: HouseholdData = { | ||
people: { | ||
person1: { age: { 2024: 30 } }, | ||
}, | ||
customEntity: { | ||
entity1: { custom_field: 'value' }, | ||
}, | ||
} as any; |
This file contains hidden or 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,77 @@ | ||
import { UserHouseholdPopulation } from '@/types/ingredients/UserPopulation'; | ||
|
||
export const mockUserHouseholdPopulation: UserHouseholdPopulation = { | ||
type: 'household', | ||
id: 'household-123', | ||
householdId: 'household-123', | ||
userId: 'user-456', | ||
label: 'My Test Household', | ||
createdAt: '2024-01-15T10:00:00Z', | ||
updatedAt: '2024-01-15T10:00:00Z', | ||
isCreated: true, | ||
} as any; | ||
|
||
export const mockUserHouseholdPopulationList: UserHouseholdPopulation[] = [ | ||
{ | ||
type: 'household', | ||
id: 'household-1', | ||
householdId: 'household-1', | ||
userId: 'user-456', | ||
label: 'First Household', | ||
createdAt: '2024-01-10T10:00:00Z', | ||
updatedAt: '2024-01-10T10:00:00Z', | ||
isCreated: true, | ||
} as any, | ||
{ | ||
type: 'household', | ||
id: 'household-2', | ||
householdId: 'household-2', | ||
userId: 'user-456', | ||
label: 'Second Household', | ||
createdAt: '2024-01-12T10:00:00Z', | ||
updatedAt: '2024-01-12T10:00:00Z', | ||
isCreated: true, | ||
} as any, | ||
]; | ||
|
||
export const mockApiResponse = { | ||
id: 'household-123', | ||
household_id: 'household-123', | ||
user_id: 'user-456', | ||
user_label: 'My Test Household', | ||
country_id: 'us', | ||
created_at: '2024-01-15T10:00:00Z', | ||
updated_at: '2024-01-15T10:00:00Z', | ||
is_default: false, | ||
}; | ||
|
||
export const mockApiResponseList = [ | ||
{ | ||
id: 'household-1', | ||
household_id: 'household-1', | ||
user_id: 'user-456', | ||
user_label: 'First Household', | ||
country_id: 'us', | ||
created_at: '2024-01-10T10:00:00Z', | ||
updated_at: '2024-01-10T10:00:00Z', | ||
is_default: true, | ||
}, | ||
{ | ||
id: 'household-2', | ||
household_id: 'household-2', | ||
user_id: 'user-456', | ||
user_label: 'Second Household', | ||
country_id: 'uk', | ||
created_at: '2024-01-12T10:00:00Z', | ||
updated_at: '2024-01-12T10:00:00Z', | ||
is_default: false, | ||
}, | ||
]; | ||
|
||
export const mockCreationPayload = { | ||
household_id: 'household-123', | ||
user_id: 'user-456', | ||
user_label: 'My Test Household', | ||
country_id: 'us', | ||
is_default: false, | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question, non-blocking: Why is this mock duplicated (with slightly reordered children) in both api and adapter fixtures?