import React from "react";
import { mount } from "enzyme";
import Slider from "../src/index";

class SliderWithBeforeChange extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      currentSlide: null
    };
    this.afterChange = this.afterChange.bind(this);
  }
  afterChange(currentSlide) {
    console.log(currentSlide, "afterChange");
    this.setState({
      currentSlide
    });
  }
  render() {
    return (
      <Slider afterChange={this.afterChange}>
        <div>slide1</div>
        <div>slide2</div>
        <div>slide3</div>
        <div>slide4</div>
      </Slider>
    );
  }
}

describe("After change Slider", function() {
  it("should render", 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})
  });
});

@@ -291,16 +291,17 @@
 s);%0A  %7D%0A
+%0A
   afterC
@@ -876,50 +876,44 @@
 %22);%0A
-%0A
     
-//TBD . fix this test%0A
+setTimeout(() =%3E %7B
 %0A    
-//
+ 
  expect(
 wrap
@@ -904,38 +904,58 @@
      expect(
-wrapper
+%0A        wrapper%0A          
 .find(
-'
+%22
 .slick-slide
@@ -967,33 +967,62 @@
 k-active
-').first().text()
+%22)%0A          .first()%0A          .text()%0A      
 ).toEqua
@@ -1023,33 +1023,32 @@
 toEqual(
-'
+%22
 slide2
-'
+%22
 );%0A    
+ 
-//
  expect(
@@ -1065,32 +1065,33 @@
 ate()).toEqual(%7B
+ 
 currentSlide: 1%7D
@@ -1089,25 +1089,35 @@
 Slide: 1
+ 
 %7D)
+;
 %0A    
-//
+%7D, 1);%0A   
  wrapper
@@ -1118,25 +1118,25 @@
 rapper.find(
-'
+%22
 .slick-next'
@@ -1134,17 +1134,17 @@
 ick-next
-'
+%22
 ).simula
@@ -1150,45 +1150,88 @@
 ate(
-'
+%22
 click
-')
+%22);
 %0A    
-// expect(wrapper
+setTimeout(() =%3E %7B%0A      expect(%0A        wrapper%0A          
 .find(
-'
+%22
 .sli
@@ -1251,33 +1251,62 @@
 k-active
-').first().text()
+%22)%0A          .first()%0A          .text()%0A      
 ).toEqua
@@ -1311,25 +1311,24 @@
 ual(
-'
+%22
 slide3
-'
+%22
 );%0A    
-//
+ 
  exp
@@ -1349,32 +1349,33 @@
 ate()).toEqual(%7B
+ 
 currentSlide: 2%7D
@@ -1377,17 +1377,27 @@
 e: 2
+ 
 %7D)
+;%0A    %7D, 1);
 %0A   
- //
  wra
@@ -1402,25 +1402,25 @@
 rapper.find(
-'
+%22
 .slick-prev'
@@ -1418,17 +1418,17 @@
 ick-prev
-'
+%22
 ).simula
@@ -1434,45 +1434,88 @@
 ate(
-'
+%22
 click
-')
+%22);
 %0A    
-// expect(wrapper
+setTimeout(() =%3E %7B%0A      expect(%0A        wrapper%0A          
 .find(
-'
+%22
 .sli
@@ -1539,25 +1539,54 @@
 tive
-').first().text()
+%22)%0A          .first()%0A          .text()%0A      
 ).to
@@ -1595,25 +1595,24 @@
 ual(
-'
+%22
 slide2
-'
+%22
 );%0A    
-//
+ 
  exp
@@ -1641,16 +1641,17 @@
 oEqual(%7B
+ 
 currentS
@@ -1657,18 +1657,31 @@
 Slide: 1
+ 
 %7D)
+;%0A    %7D, 1);
 %0A  %7D);%0A%7D

fix the afterChange-test