-
-
Notifications
You must be signed in to change notification settings - Fork 30
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
1 parent
dd4c149
commit efe8dc3
Showing
1 changed file
with
93 additions
and
5 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -23,19 +23,27 @@ beforeAll(async () => { | |
}); | ||
|
||
test('totalRecipients(): Calculate total recipients', async () => { | ||
expect(calculator.allStats().totalRecipients.total).toEqual(1); | ||
expect(calculator.allStats().totalRecipients.total).toEqual(3); | ||
}); | ||
|
||
test('totalRecipients(): Calculate active recipients', async () => { | ||
expect(calculator.allStats().totalRecipients.active).toEqual(1); | ||
}); | ||
|
||
test('totalRecipientsByOrganization(): Calculate total recipients for a particular organisation', async () => { | ||
expect(calculator.allStats().totalRecipientsByOrganization['aurora'].total).toEqual(1); | ||
expect(calculator.allStats().totalRecipientsByOrganization['aurora'].total).toEqual(2); | ||
}); | ||
|
||
test('totalRecipientsByOrganization(): Calculate active recipients for a particular organisation', async () => { | ||
expect(calculator.allStats().totalRecipientsByOrganization['aurora'].total).toEqual(1); | ||
expect(calculator.allStats().totalRecipientsByOrganization['aurora'].active).toEqual(1); | ||
}); | ||
|
||
test('totalRecipientsByOrganization(): Calculate suspended recipients for a particular organisation', async () => { | ||
expect(calculator.allStats().totalRecipientsByOrganization['aurora'].suspended).toEqual(1); | ||
}); | ||
|
||
test('totalRecipientsByOrganization(): Calculate recipients for a non-existing organisation', async () => { | ||
expect(calculator.allStats().totalRecipientsByOrganization['socialincome']?.total).toEqual(undefined); | ||
}); | ||
|
||
const org1: PartnerOrganisation = { | ||
|
@@ -44,6 +52,12 @@ const org1: PartnerOrganisation = { | |
contactNumber: '123', | ||
}; | ||
|
||
const org2: PartnerOrganisation = { | ||
name: 'socialincome', | ||
contactName: 'test2', | ||
contactNumber: '456', | ||
}; | ||
|
||
const recipient1: Recipient = { | ||
birth_date: new Date('1990-05-15'), | ||
calling_name: 'John', | ||
|
@@ -72,13 +86,87 @@ const recipient1: Recipient = { | |
successor: 'Jane Doe', | ||
}; | ||
|
||
const recipient2: Recipient = { | ||
birth_date: new Date('1990-05-15'), | ||
calling_name: 'Jane', | ||
communication_mobile_phone: { | ||
phone: 1234567890, | ||
has_whatsapp: true, | ||
whatsapp_activated: true, | ||
}, | ||
email: '[email protected]', | ||
first_name: 'Jane', | ||
gender: 'female', | ||
insta_handle: '@jane_doe', | ||
last_name: 'Doe', | ||
main_language: RecipientMainLanguage.English, | ||
mobile_money_phone: { | ||
phone: 9876543210, | ||
has_whatsapp: true, | ||
}, | ||
organisation: { id: 'aurora' } as DocumentReference<PartnerOrganisation>, | ||
om_uid: 12345, | ||
profession: 'Software Engineer', | ||
progr_status: RecipientProgramStatus.Suspended, | ||
si_start_date: new Timestamp(1609459200, 0), | ||
test_recipient: false, | ||
twitter_handle: '@john_doe_tech', | ||
successor: 'Jane Doe', | ||
}; | ||
|
||
const recipient3: Recipient = { | ||
birth_date: new Date('1990-05-15'), | ||
calling_name: 'Jack', | ||
communication_mobile_phone: { | ||
phone: 1234567890, | ||
has_whatsapp: true, | ||
whatsapp_activated: true, | ||
}, | ||
email: '[email protected]', | ||
first_name: 'Jack', | ||
gender: 'male', | ||
insta_handle: '@jack_doe', | ||
last_name: 'Doe', | ||
main_language: RecipientMainLanguage.English, | ||
mobile_money_phone: { | ||
phone: 9876543210, | ||
has_whatsapp: true, | ||
}, | ||
organisation: { id: 'socialincome' } as DocumentReference<PartnerOrganisation>, | ||
om_uid: 12345, | ||
profession: 'Software Engineer', | ||
progr_status: RecipientProgramStatus.Waitlisted, | ||
si_start_date: new Timestamp(1609459200, 0), | ||
test_recipient: false, | ||
twitter_handle: '@jack_doe_tech', | ||
successor: 'Jane Doe', | ||
}; | ||
|
||
const insertTestData = async () => { | ||
await firestoreAdmin.collection<PartnerOrganisation>(PARTNER_ORGANISATION_FIRESTORE_PATH).doc('aurora').set(org1); | ||
const recipientWithOrgRef: Recipient = { | ||
await firestoreAdmin | ||
.collection<PartnerOrganisation>(PARTNER_ORGANISATION_FIRESTORE_PATH) | ||
.doc('socialincome') | ||
.set(org2); | ||
const recipient1WithOrgRef: Recipient = { | ||
...recipient1, | ||
organisation: firestoreAdmin | ||
.collection<PartnerOrganisation>(PARTNER_ORGANISATION_FIRESTORE_PATH) | ||
.doc('aurora') as DocumentReference<PartnerOrganisation>, | ||
}; | ||
await firestoreAdmin.collection<Recipient>(RECIPIENT_FIRESTORE_PATH).add(recipientWithOrgRef); | ||
const recipient2WithOrgRef: Recipient = { | ||
...recipient2, | ||
organisation: firestoreAdmin | ||
.collection<PartnerOrganisation>(PARTNER_ORGANISATION_FIRESTORE_PATH) | ||
.doc('aurora') as DocumentReference<PartnerOrganisation>, | ||
}; | ||
const recipient3WithOrgRef: Recipient = { | ||
...recipient3, | ||
organisation: firestoreAdmin | ||
.collection<PartnerOrganisation>(PARTNER_ORGANISATION_FIRESTORE_PATH) | ||
.doc('socialincome') as DocumentReference<PartnerOrganisation>, | ||
}; | ||
await firestoreAdmin.collection<Recipient>(RECIPIENT_FIRESTORE_PATH).add(recipient1WithOrgRef); | ||
await firestoreAdmin.collection<Recipient>(RECIPIENT_FIRESTORE_PATH).add(recipient2WithOrgRef); | ||
await firestoreAdmin.collection<Recipient>(RECIPIENT_FIRESTORE_PATH).add(recipient3WithOrgRef); | ||
}; |