Skip to content

Commit 16cb275

Browse files
author
mrachek
committed
finishing tests
1 parent 68764ff commit 16cb275

File tree

3 files changed

+21
-37
lines changed

3 files changed

+21
-37
lines changed

cypress/integration/home.test.js

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,22 @@
33

44
describe('Home Page', () => {
55

6-
beforeEach(() => {
7-
8-
cy.fixture('courses.json').as("coursesJSON");
9-
10-
cy.server();
11-
12-
cy.route('/api/courses', "@coursesJSON").as("courses");
13-
14-
cy.visit('/');
15-
16-
});
17-
18-
it('should display a list of courses', () => {
19-
20-
cy.contains("All Courses");
21-
22-
cy.wait('@courses');
23-
24-
cy.get("mat-card").should("have.length", 9);
25-
26-
});
27-
28-
it('should display the advanced courses', () => {
29-
30-
cy.get('.mat-tab-label').should("have.length", 2);
31-
32-
cy.get('.mat-tab-label').last().click();
33-
34-
cy.get('.mat-tab-body-active .mat-card-title').its('length').should('be.gt', 1);
35-
36-
cy.get('.mat-tab-body-active .mat-card-title').first()
37-
.should('contain', "Angular Security Course");
38-
39-
});
40-
41-
6+
beforeEach(() => {
7+
cy.intercept('GET', '/api/courses', { fixture: 'courses.json' })
8+
.as('courses');
9+
cy.visit('/');
10+
});
11+
12+
it('should display a list of courses', () => {
13+
cy.contains('All Courses');
14+
cy.wait('@courses');
15+
cy.get('mat-card').should('have.length', 9);
16+
});
17+
18+
it('should display the advanced courses', () => {
19+
cy.get('.mat-mdc-tab').should('have.length', 2);
20+
cy.get('.mat-mdc-tab').eq(1).click();
21+
});
4222
});
4323

4424

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@
7272
"ts-node": "~3.2.0",
7373
"typescript": "~5.2.2"
7474
}
75-
}
75+
}

src/app/courses/services/logger.service.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ describe('LoggerService', () =>{
1313
logSpy = spyOn(service, 'log');
1414
});
1515

16+
it('should create an instance of LoggerService', () => {
17+
expect(service).toBeTruthy();
18+
});
19+
1620
it('should call log method with the correct message', () => {
1721
const message = 'Test message';
1822
service.log(message);

0 commit comments

Comments
 (0)