-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(#138): making SYNC_PERIOD configureable, adding tests
- Loading branch information
Showing
5 changed files
with
50 additions
and
7 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
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import request from 'supertest'; | ||
import app from '../../..'; | ||
import * as openmrs_sync from '../../utils/openmrs_sync'; | ||
import axios from 'axios'; | ||
|
||
jest.mock('axios'); | ||
|
||
describe('GET /openmrs/sync', () => { | ||
it('calls syncPatients and syncEncouners', async () => { | ||
jest.spyOn(openmrs_sync, 'syncPatients').mockImplementation(async (startTime) => { | ||
}); | ||
|
||
jest.spyOn(openmrs_sync, 'syncEncounters').mockImplementation(async (startTime) => { | ||
}); | ||
|
||
const res = await request(app).get('/openmrs/sync').send(); | ||
|
||
expect(res.status).toBe(200); | ||
|
||
expect(openmrs_sync.syncPatients).toHaveBeenCalled(); | ||
expect(openmrs_sync.syncEncounters).toHaveBeenCalled(); | ||
}); | ||
|
||
it('returns 500 if syncPatients throws an error', async () => { | ||
jest.spyOn(openmrs_sync, 'syncPatients').mockImplementation(async (startTime) => { | ||
throw new Error('Sync Failed'); | ||
}); | ||
|
||
const res = await request(app).get('/openmrs/sync').send(); | ||
|
||
expect(res.status).toBe(500); | ||
|
||
expect(openmrs_sync.syncPatients).toHaveBeenCalled(); | ||
}); | ||
}); |
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