| 1 | import { Then, When } from "@badeball/cypress-cucumber-preprocessor"; |
| 2 | |
| 3 | When( |
| 4 | "I select {string} option in the {string} selector", |
| 5 | (option: string, selector: string) => { |
| 6 | selectOption(option, selector); |
| 7 | } |
| 8 | ); |
| 9 | |
| 10 | Then( |
| 11 | "I should see {string} option in the {string} selector", |
| 12 | (option: string, selector: string) => { |
| 13 | isOptionSelected(option, selector); |
| 14 | } |
| 15 | ); |
| 16 | |
| 17 | export const selectOption = (option: string, selector: string) => { |
| 18 | cy.dataCy(selector + "-toggle").click(); |
| 19 | cy.dataCy(selector + "-toggle").should("have.attr", "aria-expanded", "true"); |
| 20 | cy.dataCy(selector + "-" + option).click(); |
| 21 | }; |
| 22 | |
| 23 | export const isOptionSelected = (option: string, selector: string) => { |
| 24 | cy.dataCy(selector + "-toggle").contains(option); |
| 25 | }; |