-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VAMC system/facilities selectors, connectors, and tests (#27557)
* selectors, connectors, and tests * rename test
- Loading branch information
Showing
5 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/platform/site-wide/drupal-static-data/source-files/vamc-system/connect/index.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,10 @@ | ||
import { connectDrupalStaticDataFile } from '../../../connect'; | ||
import { preProcessSystemData } from './preProcess'; | ||
|
||
export const connectDrupalStaticDataFileVamcSystem = dispatch => { | ||
connectDrupalStaticDataFile(dispatch, { | ||
fileName: 'vamc-system.json', | ||
preProcess: preProcessSystemData, | ||
statePropName: 'vamcSystemData', | ||
}); | ||
}; |
18 changes: 18 additions & 0 deletions
18
src/platform/site-wide/drupal-static-data/source-files/vamc-system/connect/preProcess.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,18 @@ | ||
/** | ||
* Structure of vamcSystemData: | ||
* | ||
* { | ||
* "data": { | ||
* "systems": { | ||
* "VAMC System name": { | ||
* "vhaId": "Facility name", | ||
* } | ||
* } | ||
* } | ||
* } | ||
* vhaId is used to lookup the facility in whatever other source it's needed (e.g. police data is id'ed by facility vhaId) | ||
*/ | ||
|
||
export const preProcessSystemData = vamcSystemData => { | ||
return vamcSystemData; | ||
}; |
10 changes: 10 additions & 0 deletions
10
src/platform/site-wide/drupal-static-data/source-files/vamc-system/selectors/index.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,10 @@ | ||
// breaks unit tests if we use the workspace import | ||
// eslint-disable-next-line @department-of-veterans-affairs/use-workspace-imports | ||
import { selectDrupalStaticData } from 'platform/site-wide/drupal-static-data/selectors'; | ||
|
||
export const selectVamcSystemData = state => | ||
selectDrupalStaticData(state)?.vamcSystemData?.data.systems || {}; | ||
|
||
// Returns an array of [vhaId, facilityName] tuples | ||
export const selectFacilitiesForSystem = (state, systemName) => | ||
Object.entries(selectVamcSystemData(state)?.[systemName] || {}) || []; |
40 changes: 40 additions & 0 deletions
40
...tform/site-wide/drupal-static-data/source-files/vamc-system/tests/preProcess.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,40 @@ | ||
/* eslint-disable camelcase */ | ||
import { expect } from 'chai'; | ||
import { preProcessSystemData } from '../connect/preProcess'; | ||
|
||
describe('does nothing, output format is same as source', () => { | ||
const vamcSystemData = { | ||
data: { | ||
systems: { | ||
'VA Pittsburgh health care': { | ||
vha_646GC: 'Beaver County VA Clinic', | ||
vha_646GA: 'Belmont County VA Clinic', | ||
vha_646GE: 'Fayette County VA Clinic', | ||
vha_646A4: | ||
'H. John Heinz III Department of Veterans Affairs Medical Center', | ||
vha_646GF: 'Monroeville VA Clinic', | ||
vha_646: 'Pittsburgh VA Medical Center-University Drive', | ||
vha_646GD: 'Washington County VA Clinic', | ||
vha_646GB: 'Westmoreland County VA Clinic', | ||
}, | ||
'VA Altoona health care': { | ||
vha_503GB: 'DuBois VA Clinic', | ||
vha_503GD: 'Huntingdon County VA Clinic', | ||
vha_503GE: 'Indiana County VA Clinic', | ||
vha_503: "James E. Van Zandt Veterans' Administration Medical Center", | ||
vha_503GA: 'Johnstown VA Clinic', | ||
vha_503GC: 'State College VA Clinic', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
it('returns empty objects when no data present', () => { | ||
const emptyVamcSystemData = {}; | ||
expect(preProcessSystemData(emptyVamcSystemData)).to.deep.equal({}); | ||
}); | ||
|
||
it('does not change input', () => { | ||
expect(preProcessSystemData(vamcSystemData)).to.deep.equal(vamcSystemData); | ||
}); | ||
}); |
52 changes: 52 additions & 0 deletions
52
src/platform/site-wide/drupal-static-data/source-files/vamc-system/tests/utils.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,52 @@ | ||
/* eslint-disable camelcase */ | ||
import { expect } from 'chai'; | ||
import { selectFacilitiesForSystem, selectVamcSystemData } from '../selectors'; | ||
|
||
describe('getVamcSystemNameFromVhaId', () => { | ||
const drupalStaticData = { | ||
drupalStaticData: { | ||
vamcSystemData: { | ||
data: { | ||
systems: { | ||
'VA Pittsburgh health care': { | ||
vha_646GC: 'Beaver County VA Clinic', | ||
vha_646GA: 'Belmont County VA Clinic', | ||
vha_646GE: 'Fayette County VA Clinic', | ||
vha_646A4: | ||
'H. John Heinz III Department of Veterans Affairs Medical Center', | ||
vha_646GF: 'Monroeville VA Clinic', | ||
vha_646: 'Pittsburgh VA Medical Center-University Drive', | ||
vha_646GD: 'Washington County VA Clinic', | ||
vha_646GB: 'Westmoreland County VA Clinic', | ||
}, | ||
'VA Altoona health care': { | ||
vha_503GB: 'DuBois VA Clinic', | ||
vha_503GD: 'Huntingdon County VA Clinic', | ||
vha_503GE: 'Indiana County VA Clinic', | ||
vha_503: | ||
"James E. Van Zandt Veterans' Administration Medical Center", | ||
vha_503GA: 'Johnstown VA Clinic', | ||
vha_503GC: 'State College VA Clinic', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
it('selects VAMC facility id name tuples', () => { | ||
expect(selectVamcSystemData(drupalStaticData)).to.deep.equal( | ||
drupalStaticData.drupalStaticData.vamcSystemData.data.systems, | ||
); | ||
expect( | ||
selectFacilitiesForSystem(drupalStaticData, 'VA Altoona health care'), | ||
).to.deep.equal([ | ||
['vha_503GB', 'DuBois VA Clinic'], | ||
['vha_503GD', 'Huntingdon County VA Clinic'], | ||
['vha_503GE', 'Indiana County VA Clinic'], | ||
['vha_503', "James E. Van Zandt Veterans' Administration Medical Center"], | ||
['vha_503GA', 'Johnstown VA Clinic'], | ||
['vha_503GC', 'State College VA Clinic'], | ||
]); | ||
}); | ||
}); |