|
1 |
| -import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps' |
| 1 | +import { Given, When, Then } from "cypress-cucumber-preprocessor/steps"; |
2 | 2 |
|
3 |
| -Given('I open {string} page', (uri) => { |
4 |
| - const baseUrl = 'http://localhost:3000' |
5 |
| - let path = '' |
| 3 | +Given("I open {string} page", (uri) => { |
| 4 | + const baseUrl = "http://localhost:3000"; |
| 5 | + let path = ""; |
6 | 6 | switch (uri) {
|
7 |
| - case 'home': |
8 |
| - path = '/' |
9 |
| - break |
10 |
| - case 'search': |
11 |
| - path = '/search' |
12 |
| - break |
13 |
| - case 'eddiejaoude': |
14 |
| - path = '/eddiejaoude' |
15 |
| - break |
16 |
| - case '404': |
17 |
| - path = '/abcdef' |
18 |
| - break |
| 7 | + case "home": |
| 8 | + path = "/"; |
| 9 | + break; |
| 10 | + case "search": |
| 11 | + path = "/search"; |
| 12 | + break; |
| 13 | + case "eddiejaoude": |
| 14 | + path = "/eddiejaoude"; |
| 15 | + break; |
| 16 | + case "404": |
| 17 | + path = "/abcdef"; |
| 18 | + break; |
19 | 19 | default:
|
20 |
| - path = uri |
| 20 | + path = uri; |
21 | 21 | }
|
22 |
| - cy.visit(baseUrl + path) |
23 |
| -}) |
| 22 | + cy.visit(baseUrl + path); |
| 23 | +}); |
24 | 24 |
|
25 | 25 | When(`I click on {string}`, (text) => {
|
26 |
| - cy.get(`a[href*="${text}"]`).click() |
27 |
| -}) |
| 26 | + cy.get(`a[href*="${text}"]`).click(); |
| 27 | +}); |
28 | 28 |
|
29 | 29 | When(`I type {string} in {string}`, (type, location) => {
|
30 |
| - cy.get(location).type(type) |
31 |
| -}) |
| 30 | + cy.get(location).type(type); |
| 31 | +}); |
32 | 32 |
|
33 | 33 | Then(`I should see {string} in the url`, (text) => {
|
34 |
| - cy.url().should('include', text) |
35 |
| -}) |
| 34 | + cy.url().should("include", text); |
| 35 | +}); |
36 | 36 |
|
37 | 37 | Then(`I see {string} as a link`, (text) => {
|
38 |
| - cy.get(`a[href*="${text}"]`).should('have.length', 1) |
39 |
| -}) |
| 38 | + cy.get(`a[href*="${text}"]`).should("have.length", 1); |
| 39 | +}); |
40 | 40 |
|
41 | 41 | Then(`I see {string} text in section {string}`, (text, location) => {
|
42 |
| - cy.get(location).should('contain', text) |
43 |
| -}) |
| 42 | + cy.get(location).should("contain", text); |
| 43 | +}); |
44 | 44 |
|
45 | 45 | Then(`I do not see {string} text in section {string}`, (text, location) => {
|
46 |
| - cy.get(location).should('not.contain', text) |
47 |
| -}) |
| 46 | + cy.get(location).should("not.contain", text); |
| 47 | +}); |
48 | 48 |
|
49 | 49 | Then(`I see {string} item on the page`, (location) => {
|
50 |
| - cy.get(location).should('be.visible') |
51 |
| -}) |
| 50 | + cy.get(location).should("be.visible"); |
| 51 | +}); |
0 commit comments