From c989be14917d58c6f0969218289299d42bf69338 Mon Sep 17 00:00:00 2001 From: viction Date: Sat, 25 Dec 2021 20:29:31 +0000 Subject: [PATCH] test: select-multiple coverage --- cypress/integration/select-multiple.spec.ts | 79 ++++++++++- public/test/select-multiple/index.html | 144 ++++++++++++++++++-- 2 files changed, 211 insertions(+), 12 deletions(-) diff --git a/cypress/integration/select-multiple.spec.ts b/cypress/integration/select-multiple.spec.ts index 6d54767..cdafe1d 100644 --- a/cypress/integration/select-multiple.spec.ts +++ b/cypress/integration/select-multiple.spec.ts @@ -1,6 +1,10 @@ describe('Choices - select multiple', () => { beforeEach(() => { - cy.visit('/select-multiple'); + cy.visit('/select-multiple', { + onBeforeLoad(win) { + cy.stub(win.console, 'warn').as('consoleWarn'); + }, + }); }); describe('scenarios', () => { @@ -865,5 +869,78 @@ describe('Choices - select multiple', () => { }); }); }); + + describe('allow html', () => { + describe('is undefined', () => { + it('logs a deprecation warning', () => { + cy.get('@consoleWarn').should( + 'be.calledOnceWithExactly', + 'Deprecation warning: allowHTML in the future will be defaulted to false. You must explicitly set it to true to properly display html tags in choices.', + ); + }); + + it('does not show as text when selected', () => { + cy.get('[data-test-hook=allowhtml-undefined]') + .find('.choices__list--multiple .choices__item') + .first() + .should(($choice) => { + expect($choice.text().trim()).to.equal('Choice 1'); + }); + }); + + it('does not show html as text in dropdown', () => { + cy.get('[data-test-hook=allowhtml-undefined]') + .find('.choices__list--dropdown .choices__list') + .children() + .first() + .should(($choice) => { + expect($choice.text().trim()).to.equal('Choice 2'); + }); + }); + }); + + describe('set to true', () => { + it('does not show as text when selected', () => { + cy.get('[data-test-hook=allowhtml-true]') + .find('.choices__list--multiple .choices__item') + + .first() + .should(($choice) => { + expect($choice.text().trim()).to.equal('Choice 1'); + }); + }); + + it('does not show html as text in dropdown', () => { + cy.get('[data-test-hook=allowhtml-true]') + .find('.choices__list--dropdown .choices__list') + .children() + .first() + .should(($choice) => { + expect($choice.text().trim()).to.equal('Choice 2'); + }); + }); + }); + + describe('set to false', () => { + it('shows html as text when selected', () => { + cy.get('[data-test-hook=allowhtml-false]') + .find('.choices__list--multiple .choices__item') + .first() + .should(($choice) => { + expect($choice.text().trim()).to.equal('Choice 1'); + }); + }); + + it('shows html as text', () => { + cy.get('[data-test-hook=allowhtml-false]') + .find('.choices__list--dropdown .choices__list') + .children() + .first() + .should(($choice) => { + expect($choice.text().trim()).to.equal('Choice 2'); + }); + }); + }); + }); }); }); diff --git a/public/test/select-multiple/index.html b/public/test/select-multiple/index.html index 113fe48..e7cc117 100644 --- a/public/test/select-multiple/index.html +++ b/public/test/select-multiple/index.html @@ -345,11 +345,43 @@ + +
+ + +
+ +
+ + +
+ +
+ + +