Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit bbe6e8e

Browse files
committed
refactor(tests): add an extra test to slick-pagination component
1 parent b37b7c4 commit bbe6e8e

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/app/modules/angular-slickgrid/components/__tests__/slick-pagination.component.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,21 @@ describe('App Component', () => {
156156
expect(component.totalItems).toBe(100);
157157
});
158158

159+
it('should create a the Slick-Pagination component in the DOM and expect different locale when changed', () => {
160+
translate.use('en');
161+
fixture.detectChanges();
162+
163+
const elm = document.querySelector('.slick-pagination');
164+
const pageInfoFromTo = fixture.debugElement.query(By.css('.page-info-from-to')).nativeElement;
165+
const pageInfoTotalItems = fixture.debugElement.query(By.css('.page-info-total-items')).nativeElement;
166+
167+
expect(translate.currentLang).toBe('en');
168+
expect(elm.innerHTML).toContain('slick-pagination-nav');
169+
expect(pageInfoFromTo.innerHTML).toBe('<span data-test="item-from">5</span>-<span data-test="item-to">10</span> of ');
170+
expect(pageInfoTotalItems.innerHTML).toBe('<span data-test="total-items">100</span> items ');
171+
expect(component.totalItems).toBe(100);
172+
});
173+
159174
it('should call changeToFirstPage() from the View and expect the pagination service to be called with correct method', fakeAsync(() => {
160175
const spy = jest.spyOn(paginationServiceStub, 'goToFirstPage');
161176

test/cypress/integration/example5.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ describe('Example 5 - OData Grid', () => {
4949
it('should change Pagination to first page with 10 items', () => {
5050
cy.get('#items-per-page-label').select('10');
5151

52-
// wait for the query to finish
52+
// wait for the query to start and finish
53+
cy.get('[data-test=status]').should('contain', 'processing...');
5354
cy.get('[data-test=status]').should('contain', 'done');
5455

5556
cy.get('[data-test=page-number-input]')
@@ -301,7 +302,8 @@ describe('Example 5 - OData Grid', () => {
301302
it('should change Pagination to first page with 10 items', () => {
302303
cy.get('#items-per-page-label').select('10');
303304

304-
// wait for the query to finish
305+
// wait for the query to start and finish
306+
cy.get('[data-test=status]').should('contain', 'processing...');
305307
cy.get('[data-test=status]').should('contain', 'done');
306308

307309
cy.get('[data-test=odata-query-result]')

0 commit comments

Comments
 (0)