-
Notifications
You must be signed in to change notification settings - Fork 6
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
ad389b7
commit a1819c1
Showing
3 changed files
with
125 additions
and
90 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
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 |
---|---|---|
@@ -1,23 +1,61 @@ | ||
import uuid from 'react-native-uuid'; | ||
|
||
import { postIdentificationForm } from '../post'; | ||
|
||
it('postIdentificationForm', async () => { | ||
const photoFile = ''; | ||
|
||
const localObject = { | ||
fname: 'Hi' | ||
}; | ||
const parseUser = uuid.v4(); | ||
|
||
const postParams = { | ||
parseClass: 'SurveyData', | ||
parseUser, | ||
photoFile, | ||
localObject | ||
}; | ||
|
||
const postedOfflineForm = await postIdentificationForm(postParams); | ||
|
||
expect(postedOfflineForm).toHaveProperty('objectId') | ||
import checkOnlineStatus from '../../../offline'; | ||
import { postHousehold, postHouseholdWithRelation, postIdentificationForm } from '../post'; | ||
|
||
jest.mock('../../../offline', () => jest.fn()); | ||
|
||
describe('test offline', () => { | ||
test('postIdentificationForm', async () => { | ||
checkOnlineStatus.mockResolvedValue(false); | ||
|
||
const postParams = { | ||
parseClass: 'SurveyData', | ||
parseUser: uuid.v4(), | ||
photoFile: '', | ||
localObject: { | ||
fname: 'Hi' | ||
} | ||
}; | ||
|
||
const postedOfflineForm = await postIdentificationForm(postParams); | ||
|
||
expect(postedOfflineForm).toHaveProperty('objectId'); | ||
}); | ||
|
||
test('postHousehold', async () => { | ||
checkOnlineStatus.mockResolvedValue(false); | ||
const postParams = { | ||
parseClass: 'Household', | ||
localObject: { | ||
latitude: 0, | ||
longitude: 0 | ||
} | ||
}; | ||
|
||
const postedOfflineHousehold = await postHousehold(postParams); | ||
|
||
expect(postedOfflineHousehold).toHaveProperty('objectId'); | ||
expect(postedOfflineHousehold.objectId).toContain('Household'); | ||
}); | ||
|
||
test('Post Household with a relationship', async () => { | ||
checkOnlineStatus.mockResolvedValue(false); | ||
|
||
const postParams = { | ||
parseParentClassID: uuid.v4(), | ||
parseParentClass: 'Household', | ||
parseClass: 'Household', | ||
localObject: { | ||
relationship: 'father', | ||
latitude: 0, | ||
longitude: 0 | ||
} | ||
}; | ||
|
||
const postedHouseholdWithRelation = await postHouseholdWithRelation(postParams); | ||
|
||
expect(postedHouseholdWithRelation).toHaveProperty('objectId'); | ||
expect(postedHouseholdWithRelation.objectId).toContain('Household'); | ||
}); | ||
}); |
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