|
@@ -59,6 +59,7 @@ function render(props: RenderProps) {
|
|
|
createOptionPrefix={props.createOptionPrefix}
|
|
createOptionPrefix={props.createOptionPrefix}
|
|
|
useFuzzySearch={props.useFuzzySearch}
|
|
useFuzzySearch={props.useFuzzySearch}
|
|
|
expandUp={props.expandUp}
|
|
expandUp={props.expandUp}
|
|
|
|
|
+ onClose={props.onClose}
|
|
|
/>
|
|
/>
|
|
|
<button type="submit">submit</button>
|
|
<button type="submit">submit</button>
|
|
|
</form>
|
|
</form>
|
|
@@ -255,6 +256,26 @@ describe('<OLAutocomplete />', function () {
|
|
|
|
|
|
|
|
cy.findByLabelText('Delete').should('not.exist')
|
|
cy.findByLabelText('Delete').should('not.exist')
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ it('calls onClose when an item is selected', function () {
|
|
|
|
|
+ const closeHandler = cy.stub().as('closeHandler')
|
|
|
|
|
+ render({ items: testItems, onClose: closeHandler })
|
|
|
|
|
+
|
|
|
|
|
+ cy.findByRole('combobox').click()
|
|
|
|
|
+ cy.findByText('Banana').click()
|
|
|
|
|
+
|
|
|
|
|
+ cy.get('@closeHandler').should('have.been.calledOnce')
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ it('calls onClose when Escape is pressed', function () {
|
|
|
|
|
+ const closeHandler = cy.stub().as('closeHandler')
|
|
|
|
|
+ render({ items: testItems, onClose: closeHandler })
|
|
|
|
|
+
|
|
|
|
|
+ cy.findByRole('combobox').click()
|
|
|
|
|
+ cy.findByRole('combobox').type('{esc}')
|
|
|
|
|
+
|
|
|
|
|
+ cy.get('@closeHandler').should('have.been.calledOnce')
|
|
|
|
|
+ })
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('clear button', function () {
|
|
describe('clear button', function () {
|