From 6100815f66cd534e705f52bc332bc3231c1c6ab9 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Mon, 4 Nov 2019 17:47:28 +0000 Subject: [PATCH] Tweak cypress tests --- cypress/integration/select-one.spec.js | 36 ++++++++++++++------------ public/test/select-one/index.html | 6 ++--- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/cypress/integration/select-one.spec.js b/cypress/integration/select-one.spec.js index 03a39bf..d09c6d6 100644 --- a/cypress/integration/select-one.spec.js +++ b/cypress/integration/select-one.spec.js @@ -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); }); }); }); diff --git a/public/test/select-one/index.html b/public/test/select-one/index.html index f676093..4532b15 100644 --- a/public/test/select-one/index.html +++ b/public/test/select-one/index.html @@ -95,14 +95,14 @@ name="choices-disabled-choice" id="choices-disabled-choice" > - + - + -
+