Skip to content

Commit

Permalink
fix the afterChange-test
Browse files Browse the repository at this point in the history
  • Loading branch information
SarahAlAshwal committed Jan 10, 2021
1 parent de674c0 commit 4c1f1dd
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions __tests__/afterChange.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class SliderWithBeforeChange extends React.Component {
};
this.afterChange = this.afterChange.bind(this);
}

afterChange(currentSlide) {
console.log(currentSlide, "afterChange");
this.setState({
Expand All @@ -33,16 +34,34 @@ describe("After change Slider", function() {
const wrapper = mount(<SliderWithBeforeChange />);
expect(wrapper.state()).toEqual({ currentSlide: null });
wrapper.find(".slick-next").simulate("click");

//TBD . fix this test

// expect(wrapper.find('.slick-slide.slick-active').first().text()).toEqual('slide2');
// expect(wrapper.state()).toEqual({currentSlide: 1})
// wrapper.find('.slick-next').simulate('click')
// expect(wrapper.find('.slick-slide.slick-active').first().text()).toEqual('slide3');
// expect(wrapper.state()).toEqual({currentSlide: 2})
// wrapper.find('.slick-prev').simulate('click')
// expect(wrapper.find('.slick-slide.slick-active').first().text()).toEqual('slide2');
// expect(wrapper.state()).toEqual({currentSlide: 1})
setTimeout(() => {
expect(
wrapper
.find(".slick-slide.slick-active")
.first()
.text()
).toEqual("slide2");
expect(wrapper.state()).toEqual({ currentSlide: 1 });
}, 1);
wrapper.find(".slick-next").simulate("click");
setTimeout(() => {
expect(
wrapper
.find(".slick-slide.slick-active")
.first()
.text()
).toEqual("slide3");
expect(wrapper.state()).toEqual({ currentSlide: 2 });
}, 1);
wrapper.find(".slick-prev").simulate("click");
setTimeout(() => {
expect(
wrapper
.find(".slick-slide.slick-active")
.first()
.text()
).toEqual("slide2");
expect(wrapper.state()).toEqual({ currentSlide: 1 });
}, 1);
});
});

0 comments on commit 4c1f1dd

Please sign in to comment.