mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-17 21:16:34 +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,
|
addItems: false,
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
it('disables the search input', () => {
|
it('disables adding new items', () => {
|
||||||
|
const newChoice = 'New Choice';
|
||||||
cy.get('[data-test-hook=add-items-disabled]')
|
cy.get('[data-test-hook=add-items-disabled]')
|
||||||
.find('.choices__input--cloned')
|
.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('allows selecting items', () => {
|
||||||
it('does not open choice dropdown', () => {
|
const choice = 'Choice 2';
|
||||||
cy.get('[data-test-hook=add-items-disabled]')
|
cy.get('[data-test-hook=add-items-disabled]')
|
||||||
.find('.choices')
|
.find('.choices__input--cloned')
|
||||||
.click()
|
.type(choice)
|
||||||
.find('.choices__list--dropdown')
|
.type('{enter}');
|
||||||
.should('not.have.class', 'is-active');
|
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,
|
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]')
|
cy.get('[data-test-hook=add-items-disabled]')
|
||||||
.find('.choices__input--cloned')
|
.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('allows selecting items', () => {
|
||||||
it('does not open choice dropdown', () => {
|
const choice = 'Choice 2';
|
||||||
cy.get('[data-test-hook=add-items-disabled]')
|
cy.get('[data-test-hook=add-items-disabled]')
|
||||||
.find('.choices')
|
.find('.choices__input--cloned')
|
||||||
.click();
|
.type(choice)
|
||||||
|
.type('{enter}');
|
||||||
cy.get('[data-test-hook=add-items-disabled]')
|
cy.get('[data-test-hook=add-items-disabled]')
|
||||||
.find('.choices__list--dropdown')
|
.find('.choices__list--single .choices__item')
|
||||||
.should('not.have.class', 'is-active');
|
.last()
|
||||||
});
|
.should($el => {
|
||||||
|
expect($el).to.contain(choice);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -415,9 +415,7 @@
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
const choicesBasic = new Choices('#choices-basic', {
|
const choicesBasic = new Choices('#choices-basic', { addItems: false, allowHTML: true, });
|
||||||
allowHTML: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
document
|
document
|
||||||
.querySelector('button.disable')
|
.querySelector('button.disable')
|
||||||
|
@ -573,7 +571,8 @@
|
||||||
|
|
||||||
new Choices('#choices-search-by-label', {
|
new Choices('#choices-search-by-label', {
|
||||||
allowHTML: true,
|
allowHTML: true,
|
||||||
searchFields: ['label']
|
searchFields: ['label'],
|
||||||
|
addItems: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
new Choices('#choices-allowhtml-undefined', {
|
new Choices('#choices-allowhtml-undefined', {
|
||||||
|
|
|
@ -435,7 +435,7 @@
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
const choicesBasic = new Choices('#choices-basic', {
|
const choicesBasic = new Choices('#choices-basic', {
|
||||||
allowHTML: true,
|
allowHTML: true, addItems: false
|
||||||
});
|
});
|
||||||
|
|
||||||
document
|
document
|
||||||
|
@ -632,7 +632,8 @@
|
||||||
|
|
||||||
new Choices('#choices-search-by-label', {
|
new Choices('#choices-search-by-label', {
|
||||||
allowHTML: true,
|
allowHTML: true,
|
||||||
searchFields: ['label']
|
searchFields: ['label'],
|
||||||
|
addItems: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
new Choices('#choices-allowhtml-undefined', {
|
new Choices('#choices-allowhtml-undefined', {
|
||||||
|
|
Loading…
Reference in a new issue