Skip to content

Commit 2a252cd

Browse files
committed
test: add unit tests and e2e tests to improve coverage
1 parent 69b9587 commit 2a252cd

4 files changed

Lines changed: 495 additions & 12 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ thumbs.db
66
*.log*
77
dist/
88
cypress/screenshots/
9-
cypress/videos/
9+
cypress/videos/
10+
cypress/downloads/

cypress/e2e/rotator.esm.cy.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,21 @@ describe('AdRotator', () => {
8888
cy.wait(1000);
8989
cy.get('#fallbackMode-placement').should('be.empty');
9090
});
91+
92+
it('should set rel attribute on ad links', () => {
93+
cy.get('#sidebar-placement-1').find('a').should('have.attr', 'rel', 'noopener nofollow noreferrer');
94+
});
95+
96+
it('should have alt attribute on images', () => {
97+
cy.get('#sidebar-placement-1').find('img').should('have.attr', 'alt');
98+
});
99+
100+
it('should have title and aria-label on links with titled ads', () => {
101+
cy.get('#sidebar-placement-1').find('a').should('have.attr', 'title');
102+
cy.get('#sidebar-placement-1').find('a').should('have.attr', 'aria-label');
103+
});
104+
105+
it('should have fadeIn class on images', () => {
106+
cy.get('#sidebar-placement-1').find('img').should('have.class', 'fadeIn');
107+
});
91108
});

cypress/e2e/rotator.umd.cy.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,21 @@ describe('AdRotator', () => {
8383
cy.wait(1000);
8484
cy.get('#fallbackMode-placement').should('be.empty');
8585
});
86+
87+
it('should set rel attribute on ad links', () => {
88+
cy.get('#sidebar-placement-1').find('a').should('have.attr', 'rel', 'noopener nofollow noreferrer');
89+
});
90+
91+
it('should have alt attribute on images', () => {
92+
cy.get('#sidebar-placement-1').find('img').should('have.attr', 'alt');
93+
});
94+
95+
it('should have title and aria-label on links with titled ads', () => {
96+
cy.get('#sidebar-placement-1').find('a').should('have.attr', 'title');
97+
cy.get('#sidebar-placement-1').find('a').should('have.attr', 'aria-label');
98+
});
99+
100+
it('should have fadeIn class on images', () => {
101+
cy.get('#sidebar-placement-1').find('img').should('have.class', 'fadeIn');
102+
});
86103
});

0 commit comments

Comments
 (0)