mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-18 05:26:35 +02:00
Tweak cypress tests
This commit is contained in:
parent
798fbdfaa8
commit
6100815f66
|
@ -963,36 +963,38 @@ describe('Choices - select one', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('disabled-first-by-options', () => {
|
||||
describe('disabling first choice via options', () => {
|
||||
beforeEach(() => {
|
||||
cy.get('[data-test-hook=disabled-first-choice-by-options]')
|
||||
cy.get('[data-test-hook=disabled-first-choice-via-options]')
|
||||
.find('.choices')
|
||||
.click();
|
||||
});
|
||||
|
||||
it('first choice is disabled', () => {
|
||||
cy.get('[data-test-hook=disabled-first-choice-by-options]')
|
||||
let disabledValue;
|
||||
|
||||
it('disables the first choice', () => {
|
||||
cy.get('[data-test-hook=disabled-first-choice-via-options]')
|
||||
.find('.choices__list--dropdown .choices__list')
|
||||
.children()
|
||||
.first()
|
||||
.should('have.class', 'choices__item--disabled');
|
||||
.should('have.class', 'choices__item--disabled')
|
||||
.then($choice => {
|
||||
disabledValue = $choice.val();
|
||||
});
|
||||
});
|
||||
|
||||
let selectValue;
|
||||
|
||||
it('first non-disabled choice is selected', () => {
|
||||
cy.get('[data-test-hook=disabled-first-choice-by-options]')
|
||||
.find('.choices__input.is-hidden')
|
||||
.then($select => {
|
||||
selectValue = $select.val();
|
||||
it('selects the first enabled choice', () => {
|
||||
cy.get('[data-test-hook=disabled-first-choice-via-options]')
|
||||
.find('.choices__input[hidden]')
|
||||
.then($option => {
|
||||
expect($option.text().trim()).to.not.equal(disabledValue);
|
||||
});
|
||||
|
||||
cy.get('[data-test-hook=disabled-first-choice-by-options]')
|
||||
.find('.choices__list--dropdown .choices__list')
|
||||
.children()
|
||||
.eq(1)
|
||||
cy.get('[data-test-hook=disabled-first-choice-via-options]')
|
||||
.find('.choices__item.choices__item--selectable')
|
||||
.first()
|
||||
.should($choice => {
|
||||
expect($choice.text().trim()).to.equal(selectValue);
|
||||
expect($choice.text().trim()).to.not.equal(disabledValue);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -95,14 +95,14 @@
|
|||
name="choices-disabled-choice"
|
||||
id="choices-disabled-choice"
|
||||
>
|
||||
<option value="Choice 1" disabled>Choice 1</option>
|
||||
<option value="Choice 1">Choice 1</option>
|
||||
<option value="Choice 2">Choice 2</option>
|
||||
<option value="Choice 3">Choice 3</option>
|
||||
<option value="Choice 4">Choice 4</option>
|
||||
<option value="Choice 4" disabled>Choice 4</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div data-test-hook="disabled-first-choice-by-options">
|
||||
<div data-test-hook="disabled-first-choice-via-options">
|
||||
<label for="choices-disabled-choice-via-options"
|
||||
>Disabled first choice by options</label
|
||||
>
|
||||
|
|
Loading…
Reference in a new issue