|
| 1 | +/* globals context, cy */ |
| 2 | +context('About', () => { |
| 3 | + beforeEach(() => { |
| 4 | + cy.visit('http://localhost:8080/about'); |
| 5 | + }); |
| 6 | + |
| 7 | + describe('Header', () => { |
| 8 | + it('should have 2 navigation links', () => { |
| 9 | + cy.get('header a').should('have.length', 2); |
| 10 | + }); |
| 11 | + |
| 12 | + it('should have _Game_ link', () => { |
| 13 | + cy.get('header a') |
| 14 | + .first() |
| 15 | + .should('have.text', 'Game') |
| 16 | + .should('have.attr', 'href') |
| 17 | + .and('include', '/'); |
| 18 | + }); |
| 19 | + |
| 20 | + it('should have _Pattern Reference_ link', () => { |
| 21 | + cy.get('header a:last') |
| 22 | + .first() |
| 23 | + .should('have.text', 'Pattern Reference') |
| 24 | + .should('have.attr', 'href') |
| 25 | + .and('include', '/patterns'); |
| 26 | + }); |
| 27 | + |
| 28 | + it('should have the current page title in a span', () => { |
| 29 | + cy.get('header span') |
| 30 | + .should('exist') |
| 31 | + .should('have.text', 'About'); |
| 32 | + }); |
| 33 | + |
| 34 | + it('should have the MODE switch', () => { |
| 35 | + cy.get('header button[data-cy=mode]').should('exist'); |
| 36 | + cy.get('header button[data-cy=mode]').should('be.visible'); |
| 37 | + }); |
| 38 | + |
| 39 | + it('should NOT have the JS switch', () => { |
| 40 | + cy.get('header button[data-cy=js]').should('not.exist'); |
| 41 | + }); |
| 42 | + }); |
| 43 | + |
| 44 | + describe('Content', () => { |
| 45 | + it('should have 2 section headers', () => { |
| 46 | + cy.get('h3').should('have.length', 2); |
| 47 | + |
| 48 | + cy.get('h3:first').should('have.text', 'The Game'); |
| 49 | + cy.get('h3:last').should('have.text', 'References'); |
| 50 | + }); |
| 51 | + }); |
| 52 | + |
| 53 | + describe('Behavior', () => { |
| 54 | + it('should switch the mode', () => { |
| 55 | + cy.get('body').should('have.css', 'background-color', 'rgb(34, 34, 34)'); |
| 56 | + cy.get('header button[data-cy=mode]').click(); |
| 57 | + cy.get('body').should('have.css', 'background-color', 'rgb(255, 255, 255)'); |
| 58 | + }); |
| 59 | + }); |
| 60 | +}); |
0 commit comments