|
| 1 | +it('RouteLink', () => { |
| 2 | + const E2E_BASE = Cypress.env('E2E_BASE') |
| 3 | + |
| 4 | + cy.visit('/components/route-link.html') |
| 5 | + |
| 6 | + cy.get(`.e2e-theme-content #home-page + ul > li`).each((el) => { |
| 7 | + cy.wrap(el).within(() => { |
| 8 | + cy.get('a').should('have.attr', 'href', E2E_BASE) |
| 9 | + cy.get('a').should('have.text', 'text') |
| 10 | + }) |
| 11 | + }) |
| 12 | + |
| 13 | + cy.get(`.e2e-theme-content #non-existent + ul > li`).each((el) => { |
| 14 | + cy.wrap(el).within(() => { |
| 15 | + cy.get('a').should('have.attr', 'href', `${E2E_BASE}non-existent.html`) |
| 16 | + cy.get('a').should('have.text', 'text') |
| 17 | + }) |
| 18 | + }) |
| 19 | + |
| 20 | + cy.get(`.e2e-theme-content #non-ascii + ul > li`).each((el) => { |
| 21 | + cy.wrap(el).within(() => { |
| 22 | + cy.get('a').should( |
| 23 | + 'have.attr', |
| 24 | + 'href', |
| 25 | + encodeURI( |
| 26 | + `${E2E_BASE}routes/non-ascii-paths/中文目录名/中文文件名.html`, |
| 27 | + ), |
| 28 | + ) |
| 29 | + cy.get('a').should('have.text', 'text') |
| 30 | + }) |
| 31 | + }) |
| 32 | + |
| 33 | + cy.get(`.e2e-theme-content #non-ascii-encoded + ul > li`).each((el) => { |
| 34 | + cy.wrap(el).within(() => { |
| 35 | + cy.get('a').should( |
| 36 | + 'have.attr', |
| 37 | + 'href', |
| 38 | + encodeURI( |
| 39 | + `${E2E_BASE}routes/non-ascii-paths/中文目录名/中文文件名.html`, |
| 40 | + ), |
| 41 | + ) |
| 42 | + cy.get('a').should('have.text', 'text') |
| 43 | + }) |
| 44 | + }) |
| 45 | + |
| 46 | + cy.get(`.e2e-theme-content #active + ul > li`).each((el, index) => { |
| 47 | + cy.wrap(el).within(() => { |
| 48 | + if (index < 2) { |
| 49 | + cy.get('a').should('have.attr', 'class', 'route-link route-link-active') |
| 50 | + } else { |
| 51 | + cy.get('a').should('have.attr', 'class', 'route-link') |
| 52 | + } |
| 53 | + cy.get('a').should('have.text', 'text') |
| 54 | + }) |
| 55 | + }) |
| 56 | + |
| 57 | + const classResults = [ |
| 58 | + 'route-link custom-class', |
| 59 | + 'route-link route-link-active custom-class', |
| 60 | + ] |
| 61 | + cy.get(`.e2e-theme-content #class + ul > li`).each((el, index) => { |
| 62 | + cy.wrap(el).within(() => { |
| 63 | + cy.get('a').should('have.attr', 'class', classResults[index]) |
| 64 | + cy.get('a').should('have.text', 'text') |
| 65 | + }) |
| 66 | + }) |
| 67 | + |
| 68 | + const attrName = ['title', 'target', 'rel', 'aria-label'] |
| 69 | + const attrValue = ['Title', '_blank', 'noopener', 'test'] |
| 70 | + |
| 71 | + cy.get(`.e2e-theme-content #attrs + ul > li`).each((el, index) => { |
| 72 | + cy.wrap(el).within(() => { |
| 73 | + cy.get('a').should('have.attr', attrName[index], attrValue[index]) |
| 74 | + }) |
| 75 | + }) |
| 76 | + |
| 77 | + cy.get(`.e2e-theme-content #slots + ul > li`).each((el, index) => { |
| 78 | + cy.wrap(el).within(() => { |
| 79 | + cy.get('a') |
| 80 | + .children() |
| 81 | + .should('have.lengthOf', index + 1) |
| 82 | + .each((el) => { |
| 83 | + cy.wrap(el).contains('span', 'text') |
| 84 | + }) |
| 85 | + }) |
| 86 | + }) |
| 87 | +}) |
0 commit comments