Skip to content

Commit

Permalink
faq e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stazrouti committed Feb 11, 2024
1 parent cc91a1b commit 5e6cdf8
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions cypress/e2e/Faq.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
describe('Faq component tests', () => {
beforeEach(() => {
cy.visit('http://localhost:3000/');
});

it('renders Faq component', () => {
cy.get('.faq-content').should('exist');
cy.get('h5').contains('FAQ');
cy.get('h2').contains('Frequently Asked Questions');
});

it('initially sets activeQ state to "q1"', () => {
cy.get('p').contains('1. What is special about comparing rental car deals?');
cy.get('#q1').should('have.class', 'active-question');
// Simulate a click to toggle the question state
cy.get('#q1').click();

// Now, the class 'active-question' should be removed
cy.get('#q1').should('not.have.class', 'active-question');
});

it('initially sets activeQ state to "q2"', () => {
// the class 'active-question' should be removed
cy.get('#q2').should('not.have.class', 'active-question');
cy.get('p').contains('2. How do I find the car rental deals?');
// Simulate a click to toggle the question state
cy.get('#q2').click();
cy.get('#q2').should('have.class', 'active-question');
cy.get('#q2').click();
cy.get('#q2').should('not.have.class', 'active-question');
});

it('initially sets activeQ state to "q3"', () => {
// the class 'active-question' should be removed
cy.get('#q3').should('not.have.class', 'active-question');
cy.get('p').contains('2. How do I find the car rental deals?');
// Simulate a click to toggle the question state
cy.get('#q3').click();
cy.get('#q3').should('have.class', 'active-question');
cy.get('#q3').click();
cy.get('#q3').should('not.have.class', 'active-question');
});

it('test open close multiple times', () => {
cy.get('#q1').click();
// the class 'active-question' should be removed
cy.get('#q1').should('not.have.class', 'active-question');
cy.get('#q2').should('not.have.class', 'active-question');
cy.get('#q3').should('not.have.class', 'active-question');

// Simulate a click to toggle the question state
cy.get('#q1').click();
cy.get('#q1').should('have.class', 'active-question');
cy.get('#q2').should('not.have.class', 'active-question');
cy.get('#q3').should('not.have.class', 'active-question');

cy.get('#q2').click();
cy.get('#q1').should('not.have.class', 'active-question');
cy.get('#q2').should('have.class', 'active-question');
cy.get('#q3').should('not.have.class', 'active-question');

cy.get('#q3').click();
cy.get('#q1').should('not.have.class', 'active-question');
cy.get('#q2').should('not.have.class', 'active-question');
cy.get('#q3').should('have.class', 'active-question');
});
});

0 comments on commit 5e6cdf8

Please sign in to comment.