import styles from './style.postcss';

import React from 'react';
import { shallow, mount } from 'enzyme';
import { expect } from 'chai';
import SessionNav from './';

describe('SessionNav', () => {
  const sessions = [{ name: 'Unit 1', date: 'Saturday, 4 June 2016' },
    { name: 'Unit 2', date: 'Saturday, 11 June 2016' },
    { name: 'Unit 3', date: 'Saturday, 18 June 2016' }];
  it('hide the back button in the first item', () => {
    const current = 0;
    const wrapper = shallow(<SessionNav items={sessions} current={current} />);
    expect(wrapper.find(`.${styles.SessionNav}`)).to.have.length(1);
    expect(wrapper.find(`.${styles.SessionNav_forward}`)).to.have.length(1);
    expect(wrapper.find(`.${styles.SessionNav_back}`)).to.have.length(0);
    expect(wrapper.find(`.${styles.SessionNav_emptyBtn}`)).to.have.length(1);
  });

  it('back and forward btn callback is working', () => {
    const wrapper = mount(<SessionNav items={sessions}
        current={0}
        onForward={() => wrapper.setProps({ current: 1 })}
        onBack={() => wrapper.setProps({ current: 2 })} />);
    wrapper.find(`.${styles.SessionNav_forward}`).simulate('click');
    expect(wrapper.prop('current')).to.eql(1);
    wrapper.find(`.${styles.SessionNav_back}`).simulate('click');
    expect(wrapper.prop('current')).to.eql(2);
  });
});

@@ -839,16 +839,952 @@
 %0A  %7D);%0A%0A
+  it('display forward&back button in the second item', () =%3E %7B%0A    const current = 1;%0A    const wrapper = shallow(%3CSessionNav items=%7Bsessions%7D current=%7Bcurrent%7D /%3E);%0A    expect(wrapper.find(%60.$%7Bstyles.SessionNav%7D%60)).to.have.length(1);%0A    expect(wrapper.find(%60.$%7Bstyles.SessionNav_forward%7D%60)).to.have.length(1);%0A    expect(wrapper.find(%60.$%7Bstyles.SessionNav_back%7D%60)).to.have.length(1);%0A    expect(wrapper.find(%60.$%7Bstyles.SessionNav_emptyBtn%7D%60)).to.have.length(0);%0A  %7D);%0A%0A  it('hide the forward button in the last item', () =%3E %7B%0A    const current = 2;%0A    const wrapper = shallow(%3CSessionNav items=%7Bsessions%7D current=%7Bcurrent%7D /%3E);%0A    expect(wrapper.find(%60.$%7Bstyles.SessionNav%7D%60)).to.have.length(1);%0A    expect(wrapper.find(%60.$%7Bstyles.SessionNav_forward%7D%60)).to.have.length(0);%0A    expect(wrapper.find(%60.$%7Bstyles.SessionNav_back%7D%60)).to.have.length(1);%0A    expect(wrapper.find(%60.$%7Bstyles.SessionNav_emptyBtn%7D%60)).to.have.length(1);%0A  %7D);%0A%0A
   it('ba
@@ -1904,17 +1904,17 @@
 urrent=%7B
-0
+1
 %7D%0A      
@@ -1960,17 +1960,17 @@
 urrent: 
-1
+2
  %7D)%7D%0A   
@@ -2012,25 +2012,25 @@
 (%7B current: 
-2
+0
  %7D)%7D /%3E);%0A  
@@ -2139,17 +2139,17 @@
 .to.eql(
-1
+2
 );%0A    w
@@ -2248,24 +2248,594 @@
 t')).to.eql(
+0);%0A  %7D);%0A%7D);%0A%0Adescribe('SessionNav', () =%3E %7B%0A  const sessions = %5B%7B name: 'Unit 1', date: 'Saturday, 4 June 2016' %7D%5D;%0A  it('hide the back button in the first item', () =%3E %7B%0A    const current = 0;%0A    const wrapper = shallow(%3CSessionNav items=%7Bsessions%7D current=%7Bcurrent%7D /%3E);%0A    expect(wrapper.find(%60.$%7Bstyles.SessionNav%7D%60)).to.have.length(1);%0A    expect(wrapper.find(%60.$%7Bstyles.SessionNav_forward%7D%60)).to.have.length(0);%0A    expect(wrapper.find(%60.$%7Bstyles.SessionNav_back%7D%60)).to.have.length(0);%0A    expect(wrapper.find(%60.$%7Bstyles.SessionNav_emptyBtn%7D%60)).to.have.length(
 2);%0A  %7D);%0A%7D)

add more unit test for SessionNav