From cf34edd0ad0b2df6767dd4540dc221826d183959 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 16 Apr 2020 05:01:21 +0200 Subject: [PATCH] fix and extend existing tests for new functionality --- cypress/e2e/select-multiple.spec.ts | 32 ++++++++++++++------- cypress/e2e/select-one.spec.ts | 39 ++++++++++++++++++-------- public/test/select-multiple/index.html | 7 ++--- public/test/select-one/index.html | 5 ++-- 4 files changed, 55 insertions(+), 28 deletions(-) diff --git a/cypress/e2e/select-multiple.spec.ts b/cypress/e2e/select-multiple.spec.ts index 0e574d8..a00e9ec 100644 --- a/cypress/e2e/select-multiple.spec.ts +++ b/cypress/e2e/select-multiple.spec.ts @@ -332,20 +332,32 @@ describe('Choices - select multiple', () => { addItems: false, } */ - it('disables the search input', () => { + it('disables adding new items', () => { + const newChoice = 'New Choice'; cy.get('[data-test-hook=add-items-disabled]') .find('.choices__input--cloned') - .should('be.disabled'); + .type(newChoice) + .type('{enter}'); + cy.get('[data-test-hook=add-items-disabled]') + .find('.choices__list--multiple') + .last() + .should($el => { + expect($el).to.not.contain(newChoice); + }); }); - describe('on click', () => { - it('does not open choice dropdown', () => { - cy.get('[data-test-hook=add-items-disabled]') - .find('.choices') - .click() - .find('.choices__list--dropdown') - .should('not.have.class', 'is-active'); - }); + it('allows selecting items', () => { + const choice = 'Choice 2'; + cy.get('[data-test-hook=add-items-disabled]') + .find('.choices__input--cloned') + .type(choice) + .type('{enter}'); + cy.get('[data-test-hook=add-items-disabled]') + .find('.choices__list--multiple') + .last() + .should($el => { + expect($el).to.contain(choice); + }); }); }); diff --git a/cypress/e2e/select-one.spec.ts b/cypress/e2e/select-one.spec.ts index 8494b9f..a8fa65a 100644 --- a/cypress/e2e/select-one.spec.ts +++ b/cypress/e2e/select-one.spec.ts @@ -300,22 +300,37 @@ describe('Choices - select one', () => { addItems: false, } */ - it('disables the search input', () => { + beforeEach(() => { + cy.get('[data-test-hook=add-items-disabled]') + .find('.choices') + .click(); + }); + it('disables adding new items', () => { + const newChoice = 'New Choice'; cy.get('[data-test-hook=add-items-disabled]') .find('.choices__input--cloned') - .should('be.disabled'); + .type(newChoice) + .type('{enter}'); + cy.get('[data-test-hook=add-items-disabled]') + .find('.choices__list--single .choices__item') + .last() + .should($el => { + expect($el).to.not.contain(newChoice); + }); }); - describe('on click', () => { - it('does not open choice dropdown', () => { - cy.get('[data-test-hook=add-items-disabled]') - .find('.choices') - .click(); - - cy.get('[data-test-hook=add-items-disabled]') - .find('.choices__list--dropdown') - .should('not.have.class', 'is-active'); - }); + it('allows selecting items', () => { + const choice = 'Choice 2'; + cy.get('[data-test-hook=add-items-disabled]') + .find('.choices__input--cloned') + .type(choice) + .type('{enter}'); + cy.get('[data-test-hook=add-items-disabled]') + .find('.choices__list--single .choices__item') + .last() + .should($el => { + expect($el).to.contain(choice); + }); }); }); diff --git a/public/test/select-multiple/index.html b/public/test/select-multiple/index.html index d8f1145..756e771 100644 --- a/public/test/select-multiple/index.html +++ b/public/test/select-multiple/index.html @@ -415,9 +415,7 @@