mirror of
https://github.com/Choices-js/Choices.git
synced 2024-06-08 00:42:15 +02:00
fix and extend existing tests for new functionality
This commit is contained in:
parent
2c57d3a690
commit
cf34edd0ad
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -415,9 +415,7 @@
|
|||
</div>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const choicesBasic = new Choices('#choices-basic', {
|
||||
allowHTML: true,
|
||||
});
|
||||
const choicesBasic = new Choices('#choices-basic', { addItems: false, allowHTML: true, });
|
||||
|
||||
document
|
||||
.querySelector('button.disable')
|
||||
|
@ -573,7 +571,8 @@
|
|||
|
||||
new Choices('#choices-search-by-label', {
|
||||
allowHTML: true,
|
||||
searchFields: ['label']
|
||||
searchFields: ['label'],
|
||||
addItems: false,
|
||||
});
|
||||
|
||||
new Choices('#choices-allowhtml-undefined', {
|
||||
|
|
|
@ -435,7 +435,7 @@
|
|||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const choicesBasic = new Choices('#choices-basic', {
|
||||
allowHTML: true,
|
||||
allowHTML: true, addItems: false
|
||||
});
|
||||
|
||||
document
|
||||
|
@ -632,7 +632,8 @@
|
|||
|
||||
new Choices('#choices-search-by-label', {
|
||||
allowHTML: true,
|
||||
searchFields: ['label']
|
||||
searchFields: ['label'],
|
||||
addItems: false,
|
||||
});
|
||||
|
||||
new Choices('#choices-allowhtml-undefined', {
|
||||
|
|
Loading…
Reference in a new issue