<commit_before>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);
  });
});<commit_msg>add more unit test for SessionNav<commit_after>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: '<NAME>', 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('display forward&back button in the second item', () => {
    const current = 1;
    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(1);
    expect(wrapper.find(`.${styles.SessionNav_emptyBtn}`)).to.have.length(0);
  });

  it('hide the forward button in the last item', () => {
    const current = 2;
    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(0);
    expect(wrapper.find(`.${styles.SessionNav_back}`)).to.have.length(1);
    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={1}
        onForward={() => wrapper.setProps({ current: 2 })}
        onBack={() => wrapper.setProps({ current: 0 })} />);
    wrapper.find(`.${styles.SessionNav_forward}`).simulate('click');
    expect(wrapper.prop('current')).to.eql(2);
    wrapper.find(`.${styles.SessionNav_back}`).simulate('click');
    expect(wrapper.prop('current')).to.eql(0);
  });
});

describe('SessionNav', () => {
  const sessions = [{ name: '<NAME>', date: 'Saturday, 4 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(0);
    expect(wrapper.find(`.${styles.SessionNav_back}`)).to.have.length(0);
    expect(wrapper.find(`.${styles.SessionNav_emptyBtn}`)).to.have.length(2);
  });
});
{'fraction_non_alphanumeric': 0.20978363123236124, 'fraction_numerical': 0.018579492003762934, 'mean_word_length': 4.424744897959184, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2866907', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1367, 'n_words': 255}