-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LG-11082 - Add optional info alert to FullAddressSearch (#9276)
* Add FullAddressSearchProps to types.d.ts * Rename interfact, alpha order args * Add resultsHeaderComponent arg, alpha order * fix linter errors * increase version of identity-address-search * clean up duplicate interface * update data type and tests * delete unused var * changelog: Upcoming Features, In-person proofing, Add new optional resultsHeaderComponent prop onto FullAddressSearch so it can be passed in from help center * change data type * Move FullAddressSearchInputProps to types.d * Added logic to show/hide header and info text * moved props back inside component * Add show/hide logic to AddressSearch * fix linter errors * change prop type * change data type * update test * lint fix * add tests for address-search * fix linter errors
- Loading branch information
1 parent
8f4ef2d
commit d32eb9f
Showing
8 changed files
with
177 additions
and
43 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
app/javascript/packages/address-search/components/address-search.spec.tsx
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,64 @@ | ||
import { render } from '@testing-library/react'; | ||
import sinon from 'sinon'; | ||
import { useSandbox } from '@18f/identity-test-helpers'; | ||
import { SWRConfig } from 'swr'; | ||
import AddressSearch from './address-search'; | ||
|
||
describe('AddressSearch', () => { | ||
const sandbox = useSandbox(); | ||
const locationsURL = 'https://localhost:3000/locations/endpoint'; | ||
|
||
context('Page Heading and PO Search About Message', () => { | ||
it('both render when handleLocationSelect is not null', async () => { | ||
const handleLocationsFound = sandbox.stub(); | ||
const onSelect = sinon.stub(); | ||
const { queryByText, queryByRole } = render( | ||
<SWRConfig value={{ provider: () => new Map() }}> | ||
<AddressSearch | ||
addressSearchURL="test" | ||
disabled={false} | ||
handleLocationSelect={onSelect} | ||
locationsURL={locationsURL} | ||
onFoundLocations={handleLocationsFound} | ||
registerField={() => undefined} | ||
/> | ||
</SWRConfig>, | ||
); | ||
|
||
const heading = await queryByText('in_person_proofing.headings.po_search.location'); | ||
const aboutMessage = await queryByText( | ||
'in_person_proofing.body.location.po_search.po_search_about', | ||
); | ||
|
||
expect(heading).to.exist(); | ||
expect(aboutMessage).to.exist(); | ||
expect( | ||
queryByRole('heading', { name: 'in_person_proofing.headings.po_search.location' }), | ||
).to.exist(); | ||
}); | ||
|
||
it('both do not render when handleLocationSelect is null', async () => { | ||
const handleLocationsFound = sandbox.stub(); | ||
const onSelect = sinon.stub(); | ||
const { queryByText } = render( | ||
<SWRConfig value={{ provider: () => new Map() }}> | ||
<AddressSearch | ||
addressSearchURL="test" | ||
disabled={false} | ||
handleLocationSelect={onSelect} | ||
locationsURL={locationsURL} | ||
onFoundLocations={handleLocationsFound} | ||
registerField={() => undefined} | ||
/> | ||
</SWRConfig>, | ||
); | ||
|
||
const heading = await queryByText('in_person_proofing.headings.po_search.location'); | ||
const aboutMessage = await queryByText( | ||
'in_person_proofing.body.location.po_search.po_search_about', | ||
); | ||
expect(heading).to.be.empty; | ||
expect(aboutMessage).to.be.empty; | ||
}); | ||
}); | ||
}); |
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
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