Skip to content

Commit

Permalink
Chore: Using testContainsOrNotExists helper function and tidy up of g…
Browse files Browse the repository at this point in the history
…etData call (#177)
  • Loading branch information
cahirodoherty-learningpool authored Feb 2, 2024
1 parent 5298ecf commit 6f2ab4f
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions test/e2e/adapt-contrib-boxMenu.cy.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
describe('Menu Page', function () {
beforeEach(function () {
cy.getData().then(function (data) {
this.data = data;
cy.visit('/');
});
cy.getData();
cy.visit('/');
});

it(`should have the correct title and description`, function () {
Expand All @@ -22,32 +20,17 @@ describe('Menu Page', function () {
cy.get($item).within(function () {
const { _graphic, body, displayTitle, duration, linkText } = this.data.contentObjects[index];

cy.testContainsOrNotExists('.menu-item__title', displayTitle);
cy.testContainsOrNotExists('.menu-item__body', body);
cy.testContainsOrNotExists('.menu-item__duration', duration);

if (_graphic?.src) {
cy.get('img.menu-item__image').should('exist').should('have.attr', 'src', _graphic.src);
} else {
cy.get('img.menu-item__image').should('not.exist');
}

if (displayTitle) {
cy.get('.menu-item__title').should('contain', displayTitle);
} else {
cy.get('.menu-item__title').should('not.exist');
}

cy.get('.menu-item__details-inner').should('contain', _graphic.alt);

if (body) {
cy.get('.menu-item__body').should('contain', body);
} else {
cy.get('.menu-item__body').should('not.exist');
}

if (duration) {
cy.get('.menu-item__duration').should('contain', duration);
} else {
cy.get('.menu-item__duration').should('not.exist');
}

cy.get('button.boxmenu-item__button').should('contain', linkText);
});
});
Expand Down

0 comments on commit 6f2ab4f

Please sign in to comment.