From e2f5f59c7fc9d613725baef8404b56c56dd0117c Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Tue, 19 Nov 2019 21:18:39 +0000 Subject: [PATCH] Add cypress tests covering change --- cypress/integration/select-one.spec.js | 42 +++++++++++++++++++++----- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/cypress/integration/select-one.spec.js b/cypress/integration/select-one.spec.js index 3d2c35d..e4972fb 100644 --- a/cypress/integration/select-one.spec.js +++ b/cypress/integration/select-one.spec.js @@ -5,13 +5,6 @@ describe('Choices - select one', () => { describe('scenarios', () => { describe('basic', () => { - beforeEach(() => { - // open dropdown - cy.get('[data-test-hook=basic]') - .find('.choices') - .click(); - }); - describe('focusing on container', () => { describe('pressing enter key', () => { it('toggles the dropdown', () => { @@ -22,16 +15,35 @@ describe('Choices - select one', () => { cy.get('[data-test-hook=basic]') .find('.choices__list--dropdown') - .should('not.be.visible'); + .should('be.visible'); cy.get('[data-test-hook=basic]') .find('.choices') .focus() .type('{enter}'); + cy.get('[data-test-hook=basic]') + .find('.choices__list--dropdown') + .should('not.be.visible'); + }); + }); + + describe('pressing an alpha-numeric key', () => { + it('opens the dropdown and the input value', () => { + const inputValue = 'test'; + + cy.get('[data-test-hook=basic]') + .find('.choices') + .focus() + .type(inputValue); + cy.get('[data-test-hook=basic]') .find('.choices__list--dropdown') .should('be.visible'); + + cy.get('[data-test-hook=basic]') + .find('.choices__input--cloned') + .should('have.value', inputValue); }); }); }); @@ -67,6 +79,13 @@ describe('Choices - select one', () => { }); describe('selecting choices', () => { + beforeEach(() => { + // open dropdown + cy.get('[data-test-hook=basic]') + .find('.choices') + .click(); + }); + const selectedChoiceText = 'Choice 1'; it('allows selecting choices from dropdown', () => { @@ -102,6 +121,13 @@ describe('Choices - select one', () => { }); describe('searching choices', () => { + beforeEach(() => { + // open dropdown + cy.get('[data-test-hook=basic]') + .find('.choices') + .click(); + }); + describe('on input', () => { describe('searching by label', () => { it('displays choices filtered by inputted value', () => {