diff --git a/app/components/Pagination/Pagination.spec.jsx b/app/components/Pagination/Pagination.spec.jsx index a71cce2..6774da5 100644 --- a/app/components/Pagination/Pagination.spec.jsx +++ b/app/components/Pagination/Pagination.spec.jsx @@ -9,6 +9,18 @@ describe('', () => { expect(wrapper).toMatchSnapshot(); }); + it('should have .Pagination__button--disabled when props.currentPage === 1', () => { + const wrapper = shallow(); + const button = wrapper.find('.Pagination__button--disabled'); + expect(button.props()['data-button']).toBe('prev'); + }); + + it('should have .Pagination__button--disabled when props.currentPage === 10', () => { + const wrapper = shallow(); + const button = wrapper.find('.Pagination__button--disabled'); + expect(button.props()['data-button']).toBe('next'); + }); + it('should calls onPaginate with currentPage - 1 when simulate prev button click event', () => { const currentPage = 3; const onPaginate = jest.fn(); @@ -20,8 +32,8 @@ describe('', () => { /> )); wrapper.find('.Pagination__button').at(0).simulate('click'); - expect(onPaginate.mock.calls.length).toBe(1); - expect(onPaginate.mock.calls[0]).toEqual([currentPage - 1]); + expect(onPaginate).toHaveBeenCalledTimes(1); + expect(onPaginate).toHaveBeenCalledWith(currentPage - 1); }); it('should calls onPaginate with currentPage + 1 when simulate next button click event', () => { @@ -35,7 +47,7 @@ describe('', () => { /> )); wrapper.find('.Pagination__button').at(1).simulate('click'); - expect(onPaginate.mock.calls.length).toBe(1); - expect(onPaginate.mock.calls[0]).toEqual([currentPage + 1]); + expect(onPaginate).toHaveBeenCalledTimes(1); + expect(onPaginate).toHaveBeenCalledWith(currentPage + 1); }); }); diff --git a/app/components/Pagination/__snapshots__/Pagination.spec.jsx.snap b/app/components/Pagination/__snapshots__/Pagination.spec.jsx.snap index f439d37..b0d4e2d 100644 --- a/app/components/Pagination/__snapshots__/Pagination.spec.jsx.snap +++ b/app/components/Pagination/__snapshots__/Pagination.spec.jsx.snap @@ -9,6 +9,7 @@ exports[` should match snapshot when render default 1`] = ` > + 1 + / 10 + {currentPage} / 10 {' '}