Skip to content

Commit

Permalink
feat: preselect and fall back to normal location altitudinal zone for…
Browse files Browse the repository at this point in the history
… transition
  • Loading branch information
friedjoff committed May 6, 2020
1 parent b0515e6 commit b444cde
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/src/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function project(location = {}, targetAltitude, previousResult) {
if (location.transitionForestType) {
const { transitionForestType, transitionAltitudinalZone, ...tl } = location;
tl.forestType = transitionForestType;
tl.altitudinalZone = transitionAltitudinalZone;
tl.altitudinalZone = transitionAltitudinalZone || tl.altitudinalZone;
const transition = project(tl, targetAltitude);
const tp = transition.projections || [];
Object.entries(transition.options).forEach(([k, v]) => {
Expand Down
15 changes: 15 additions & 0 deletions lib/test/project.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,21 @@ describe('valid projections', () => {
});
});

test('projection with valid transitionForestType but missing transitionAltitudinalZone', () => {
expect(
project(
{
forestEcoregion: '1',
forestType: '19f',
transitionForestType: '46',
altitudinalZone: '60',
slope: '<20',
},
'50',
).projections[0].transitionForestType,
).toBe('8*');
});

test('projection with transitionForestType not found', () => {
expect(
project(
Expand Down
5 changes: 4 additions & 1 deletion src/components/ProjectionForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ function ProjectionForm() {
}}
onBlur={deactivateField}
onFocus={() => activateField('transitionAltitudinalZone')}
value={getValue('altitudinalZone', { transition: true })}
value={
getValue('altitudinalZone', { transition: true }) ||
getValue('altitudinalZone')
}
/>
</Segment>
)}
Expand Down

0 comments on commit b444cde

Please sign in to comment.