-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor of the Time since separation page to use web components (#32142
) * Refactor separation form page to use web components * Add unit test * Update hint label * Repair unit tests
- Loading branch information
Showing
7 changed files
with
83 additions
and
64 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
39 changes: 12 additions & 27 deletions
39
src/applications/benefit-eligibility-questionnaire/pages/separation.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 |
---|---|---|
@@ -1,38 +1,23 @@ | ||
import { pageTitle } from '../utils/helpers'; | ||
import { | ||
radioSchema, | ||
radioUI, | ||
} from 'platform/forms-system/src/js/web-component-patterns'; | ||
import { separationTypes, separationTypeLabels } from '../constants/benefits'; | ||
|
||
export default { | ||
uiSchema: { | ||
separation: { | ||
'ui:title': pageTitle( | ||
'How long ago did you separate or retire from service?', | ||
separation: radioUI({ | ||
title: 'How long ago did you separate or retire from service?', | ||
hint: | ||
'If you served during multiple periods, please choose the answer that corresponds to your most recent separation.', | ||
), | ||
'ui:widget': 'radio', | ||
'ui:options': { | ||
labels: { | ||
upTo6mo: 'Within the past 6 months', | ||
upTo1yr: 'More than 6 months ago but less than 1 year ago', | ||
upTo2yr: 'More than 1 year ago but less than 2 years ago', | ||
upTo3yr: 'More than 2 years ago but less than 3 years ago', | ||
over3yr: 'More than 3 years ago', | ||
}, | ||
widgetProps: { | ||
upTo6mo: { separation: 'upTo6mo' }, | ||
upTo1yr: { separation: 'upTo1yr' }, | ||
upTo2yr: { separation: 'upTo2yr' }, | ||
upTo3yr: { separation: 'upTo3yr' }, | ||
over3yr: { separation: 'over3yr' }, | ||
}, | ||
}, | ||
}, | ||
labels: separationTypeLabels, | ||
required: () => false, | ||
}), | ||
}, | ||
schema: { | ||
type: 'object', | ||
properties: { | ||
separation: { | ||
type: 'string', | ||
enum: ['upTo6mo', 'upTo1yr', 'upTo2yr', 'upTo3yr', 'over3yr'], | ||
}, | ||
separation: radioSchema(Object.keys(separationTypes)), | ||
}, | ||
}, | ||
}; |
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
54 changes: 27 additions & 27 deletions
54
...ications/benefit-eligibility-questionnaire/tests/unit/pages/disabilityRating.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 |
---|---|---|
@@ -1,27 +1,27 @@ | ||
import { $ } from '@department-of-veterans-affairs/platform-forms-system/ui'; | ||
import { DefinitionTester } from '@department-of-veterans-affairs/platform-testing/schemaform-utils'; | ||
import { render } from '@testing-library/react'; | ||
import { expect } from 'chai'; | ||
import React from 'react'; | ||
import { Provider } from 'react-redux'; | ||
import { getData } from '../mocks/mockFormData'; | ||
import disabilityRatingConfig from '../../../pages/disabilityRating'; | ||
|
||
describe('disabilityRating page', () => { | ||
it('should render the correct radio component', () => { | ||
const { container } = render( | ||
<Provider store={{ ...getData().mockStore }}> | ||
<DefinitionTester | ||
definitions={{}} | ||
schema={disabilityRatingConfig.schema} | ||
uiSchema={disabilityRatingConfig.uiSchema} | ||
data={{}} | ||
formData={{}} | ||
/> | ||
, | ||
</Provider>, | ||
); | ||
|
||
expect($('va-radio', container)).to.exist; | ||
}); | ||
}); | ||
import { $ } from '@department-of-veterans-affairs/platform-forms-system/ui'; | ||
import { DefinitionTester } from '@department-of-veterans-affairs/platform-testing/schemaform-utils'; | ||
import { render } from '@testing-library/react'; | ||
import { expect } from 'chai'; | ||
import React from 'react'; | ||
import { Provider } from 'react-redux'; | ||
import { getData } from '../mocks/mockFormData'; | ||
import disabilityRatingConfig from '../../../pages/disabilityRating'; | ||
|
||
describe('disabilityRating page', () => { | ||
it('should render the correct radio component', () => { | ||
const { container } = render( | ||
<Provider store={{ ...getData().mockStore }}> | ||
<DefinitionTester | ||
definitions={{}} | ||
schema={disabilityRatingConfig.schema} | ||
uiSchema={disabilityRatingConfig.uiSchema} | ||
data={{}} | ||
formData={{}} | ||
/> | ||
, | ||
</Provider>, | ||
); | ||
|
||
expect($('va-radio', container)).to.exist; | ||
}); | ||
}); |
26 changes: 26 additions & 0 deletions
26
src/applications/benefit-eligibility-questionnaire/tests/unit/pages/separation.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 { $ } from '@department-of-veterans-affairs/platform-forms-system/ui'; | ||
import { DefinitionTester } from '@department-of-veterans-affairs/platform-testing/schemaform-utils'; | ||
import { render } from '@testing-library/react'; | ||
import { expect } from 'chai'; | ||
import React from 'react'; | ||
import { Provider } from 'react-redux'; | ||
import { getData } from '../mocks/mockFormData'; | ||
import separationConfig from '../../../pages/separation'; | ||
|
||
describe('separation page', () => { | ||
it('should render the correct radio component', () => { | ||
const { container } = render( | ||
<Provider store={{ ...getData().mockStore }}> | ||
<DefinitionTester | ||
definitions={{}} | ||
schema={separationConfig.schema} | ||
uiSchema={separationConfig.uiSchema} | ||
data={{}} | ||
formData={{}} | ||
/> | ||
, | ||
</Provider>, | ||
); | ||
expect($('va-radio', container)).to.exist; | ||
}); | ||
}); |