diff --git a/cypress/integration/select-multiple.spec.js b/cypress/integration/select-multiple.spec.js index 731721b..d7db618 100644 --- a/cypress/integration/select-multiple.spec.js +++ b/cypress/integration/select-multiple.spec.js @@ -853,5 +853,35 @@ describe('Choices - select multiple', () => { }); }); }); + + describe('searching by label only', () => { + it('gets zero results when searching by value', () => { + cy.get('[data-test-hook=search-by-label]') + .find('.choices__input--cloned') + .type('value1'); + + cy.get('[data-test-hook=search-by-label]') + .find('.choices__list--dropdown .choices__list') + .children() + .first() + .should($choice => { + expect($choice.text().trim()).to.equal('No results found'); + }); + }); + + it('gets a result when searching by label', () => { + cy.get('[data-test-hook=search-by-label]') + .find('.choices__input--cloned') + .type('label1'); + + cy.get('[data-test-hook=search-by-label]') + .find('.choices__list--dropdown .choices__list') + .children() + .first() + .should($choice => { + expect($choice.text().trim()).to.equal('label1'); + }); + }); + }); }); }); diff --git a/cypress/integration/select-one.spec.js b/cypress/integration/select-one.spec.js index f2d331e..2ff287d 100644 --- a/cypress/integration/select-one.spec.js +++ b/cypress/integration/select-one.spec.js @@ -867,5 +867,41 @@ describe('Choices - select one', () => { }); }); }); + + describe('searching by label only', () => { + beforeEach(() => { + cy.get('[data-test-hook=search-by-label]') + .find('.choices') + .click(); + }); + + it('gets zero results when searching by value', () => { + cy.get('[data-test-hook=search-by-label]') + .find('.choices__input--cloned') + .type('value1'); + + cy.get('[data-test-hook=search-by-label]') + .find('.choices__list--dropdown .choices__list') + .children() + .first() + .should($choice => { + expect($choice.text().trim()).to.equal('No results found'); + }); + }); + + it('gets a result when searching by label', () => { + cy.get('[data-test-hook=search-by-label]') + .find('.choices__input--cloned') + .type('label1'); + + cy.get('[data-test-hook=search-by-label]') + .find('.choices__list--dropdown .choices__list') + .children() + .first() + .should($choice => { + expect($choice.text().trim()).to.equal('label1'); + }); + }); + }); }); }); diff --git a/public/test/select-multiple.html b/public/test/select-multiple.html index 5b1d1dc..a2a7621 100644 --- a/public/test/select-multiple.html +++ b/public/test/select-multiple.html @@ -194,6 +194,14 @@ + +