From 69ee88ae8863bf1cca2ab31855d8bc67b5b7f335 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Thu, 18 Oct 2018 22:18:17 +0100 Subject: [PATCH] Add plcaeholder tests --- cypress/integration/select-multiple.spec.js | 19 +++++++++++--- cypress/integration/text.spec.js | 16 ++++++++++++ public/test/select-multiple.html | 28 +++++++++++++++------ public/test/select-one.html | 14 +++++------ public/test/text.html | 28 ++++++++++++++------- 5 files changed, 79 insertions(+), 26 deletions(-) diff --git a/cypress/integration/select-multiple.spec.js b/cypress/integration/select-multiple.spec.js index d020ffe..c6bdbff 100644 --- a/cypress/integration/select-multiple.spec.js +++ b/cypress/integration/select-multiple.spec.js @@ -197,7 +197,6 @@ describe('Choices - select multiple', () => { removeItemButton: true, }; */ - beforeEach(() => { cy.get('[data-test-hook=remove-button]') .find('.choices__input--cloned') @@ -259,7 +258,6 @@ describe('Choices - select multiple', () => { maxItemCount: 5, }; */ - const selectionLimit = 5; beforeEach(() => { @@ -347,7 +345,6 @@ describe('Choices - select multiple', () => { renderChoiceLimit: 1, }; */ - it('only displays given number of choices in the dropdown', () => { cy.get('[data-test-hook=render-choice-limit]') .find('.choices__list--dropdown .choices__list') @@ -401,5 +398,21 @@ describe('Choices - select multiple', () => { }); }); }); + + describe('placeholder', () => { + /* + { + placeholder: true, + placeholderValue: 'I am a placeholder', + } + */ + describe('when no value has been inputted', () => { + it('displays a placeholder', () => { + cy.get('[data-test-hook=placeholder]') + .find('.choices__input--cloned') + .should('have.attr', 'placeholder', 'I am a placeholder'); + }); + }); + }); }); }); diff --git a/cypress/integration/text.spec.js b/cypress/integration/text.spec.js index 181cca3..8aa288f 100644 --- a/cypress/integration/text.spec.js +++ b/cypress/integration/text.spec.js @@ -283,5 +283,21 @@ describe('Choices - text element', () => { }); }); }); + + describe('placeholder', () => { + /* + { + placeholder: true, + placeholderValue: 'I am a placeholder', + } + */ + describe('when no value has been inputted', () => { + it('displays a placeholder', () => { + cy.get('[data-test-hook=placeholder]') + .find('.choices__input--cloned') + .should('have.attr', 'placeholder', 'I am a placeholder'); + }); + }); + }); }); }); diff --git a/public/test/select-multiple.html b/public/test/select-multiple.html index ea909a2..73a5ebc 100644 --- a/public/test/select-multiple.html +++ b/public/test/select-multiple.html @@ -31,7 +31,7 @@

Select multiple inputs

- @@ -41,7 +41,7 @@
- @@ -51,7 +51,7 @@
- @@ -61,7 +61,7 @@
- @@ -73,7 +73,7 @@
- @@ -82,7 +82,7 @@
- @@ -91,7 +91,16 @@
- + + + + +
+ +
+ + + + + + + + + +
- +
- +
- +
- +
- +
- +
- +
- + +
+ +
+ +
@@ -118,6 +123,11 @@ } }], }); + + new Choices('#choices-placeholder', { + placeholder: true, + placeholderValue: 'I am a placeholder', + }); });