-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added provider generator util. * added new mock for provider using generator. * add test * rename func and add tests. * provider mock redux stuff * return error rather than null * added error provider for testing * remove try/catch in service since error handing is occurring in other try/catch * revert test data
- Loading branch information
Showing
9 changed files
with
205 additions
and
18 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
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
26 changes: 26 additions & 0 deletions
26
src/applications/vaos/referral-appointments/tests/utils/provider.unit.spec.js
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,26 @@ | ||
import { addDays, startOfDay, addHours } from 'date-fns'; | ||
import { expect } from 'chai'; | ||
|
||
const providerUtil = require('../../utils/provider'); | ||
|
||
describe('VAOS provider generator', () => { | ||
const tomorrow = addDays(startOfDay(new Date()), 1); | ||
describe('createProviderDetails', () => { | ||
const providerObjectTwoSlots = providerUtil.createProviderDetails(2); | ||
const providerObjectNoSlots = providerUtil.createProviderDetails(0); | ||
it('Creates a provider with specified number of slots', () => { | ||
expect(providerObjectTwoSlots.slots.length).to.equal(2); | ||
}); | ||
it('Creates slots for tomorrow an hour apart starting at 12', () => { | ||
expect(providerObjectTwoSlots.slots[0].start).to.equal( | ||
addHours(tomorrow, 12).toISOString(), | ||
); | ||
expect(providerObjectTwoSlots.slots[1].start).to.equal( | ||
addHours(tomorrow, 13).toISOString(), | ||
); | ||
}); | ||
it('Creates empty slots array with 0', () => { | ||
expect(providerObjectNoSlots.slots.length).to.equal(0); | ||
}); | ||
}); | ||
}); |
43 changes: 43 additions & 0 deletions
43
src/applications/vaos/referral-appointments/utils/provider.js
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,43 @@ | ||
/* eslint-disable no-plusplus */ | ||
const dateFns = require('date-fns'); | ||
|
||
/** | ||
* Creates a provider object with a configurable number of slots an hour apart. | ||
* | ||
* @param {Number} numberOfSlots How many slots to create | ||
* @returns {Object} Provider object | ||
*/ | ||
const createProviderDetails = numberOfSlots => { | ||
const slots = []; | ||
const tomorrow = dateFns.addDays(dateFns.startOfDay(new Date()), 1); | ||
let hourFromNow = 12; | ||
for (let i = 0; i < numberOfSlots; i++) { | ||
const startTime = dateFns.addHours(tomorrow, hourFromNow); | ||
slots.push({ | ||
end: dateFns.addMinutes(startTime, 30).toISOString(), | ||
id: Math.floor(Math.random() * 90000) + 10000, | ||
start: startTime.toISOString(), | ||
}); | ||
hourFromNow++; | ||
} | ||
return { | ||
providerName: 'Dr. Face', | ||
typeOfCare: 'Dermatology', | ||
orgName: 'New Skin Technologies', | ||
orgAddress: { | ||
street1: '111 Lori Ln.', | ||
street2: '', | ||
street3: '', | ||
city: 'New York', | ||
state: 'New York', | ||
zip: '10016', | ||
}, | ||
orgPhone: '555-867-5309', | ||
driveTime: '7 minute drive', | ||
driveDistance: '8 miles', | ||
slots, | ||
location: 'New skin technologies bldg 2', | ||
}; | ||
}; | ||
|
||
module.exports = { createProviderDetails }; |
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