diff --git a/cypress/integration/select-one.spec.js b/cypress/integration/select-one.spec.js index c44c907..3d2c35d 100644 --- a/cypress/integration/select-one.spec.js +++ b/cypress/integration/select-one.spec.js @@ -1022,5 +1022,39 @@ describe('Choices - select one', () => { }); }); }); + + describe('re-initialising a choices instance', () => { + it('preserves the choices list', () => { + cy.get('[data-test-hook=new-destroy-init]') + .find('.choices__list--dropdown .choices__list') + .children() + .should('have.length', 3); + + cy.get('[data-test-hook=new-destroy-init]') + .find('button.destroy') + .click(); + cy.get('[data-test-hook=new-destroy-init]') + .find('button.init') + .click(); + + cy.get('[data-test-hook=new-destroy-init]') + .find('.choices__list--dropdown .choices__list') + .children() + .should('have.length', 3); + }); + }); + + describe('destroying the choices instance', () => { + it('preserves the original select element', () => { + cy.get('[data-test-hook=new-destroy-init]') + .find('button.destroy') + .click(); + + cy.get('[data-test-hook=new-destroy-init]') + .find('select') + .children() + .should('have.length', 3); + }); + }); }); }); diff --git a/public/test/select-one/index.html b/public/test/select-one/index.html index 4532b15..b567b28 100644 --- a/public/test/select-one/index.html +++ b/public/test/select-one/index.html @@ -359,6 +359,21 @@ + +