| 1 | import { Then, When } from "@badeball/cypress-cucumber-preprocessor"; |
| 2 | |
| 3 | export const typeInTextbox = (textbox: string, text: string) => { |
| 4 | cy.dataCy(textbox).clear(); |
| 5 | cy.dataCy(textbox).should("have.value", ""); |
| 6 | cy.dataCy(textbox).type(text); |
| 7 | }; |
| 8 | |
| 9 | When( |
| 10 | "I type in the {string} textbox text {string}", |
| 11 | (textbox: string, text: string) => { |
| 12 | typeInTextbox(textbox, text); |
| 13 | } |
| 14 | ); |
| 15 | |
| 16 | Then( |
| 17 | "I should see {string} in the {string} textbox", |
| 18 | (text: string, textbox: string) => { |
| 19 | cy.dataCy(textbox).should("have.value", text); |
| 20 | } |
| 21 | ); |
| 22 | |
| 23 | When("I clear the {string} textbox", (textbox: string) => { |
| 24 | cy.dataCy(textbox).clear(); |
| 25 | }); |
| 26 | |
| 27 | Then("I should see the {string} textbox is empty", (textbox: string) => { |
| 28 | cy.dataCy(textbox).should("have.value", ""); |
| 29 | }); |