/* eslint-disable no-unused-vars */
import React from 'react';
import enz, { mount, render, shallow } from 'enzyme';

import APILog from '.';
import datas from './mock.json';

describe('APILog', () => {
  const node = mount(<APILog link="#testing" log={datas[2]} />);
  const anotherNode = mount(<APILog link="#testing" log={datas[0]} />);
  const shallowNode = shallow(<APILog log={datas[1]} />);

  node.find('.APILog-copy').first().simulate('click');

  it('displays an API log', () => {
    expect(shallowNode.hasClass('APILog')).toBe(true);
  });

  it('displays request details', () => {
    expect(shallowNode.find('APILogRequest')).toHaveLength(1);
  });

  it('displays response details', () => {
    expect(shallowNode.find('APILogResponse')).toHaveLength(1);
  });

  it('displays tabbed request and response details', () => {
    const pre = node.find('.Tabs-listItem_active').text();
    node.find('.Tabs-listItem').at(2).simulate('click');
    const post = node.find('.Tabs-listItem_active').text();
    expect(pre).toBe('Request');
    expect(post).toBe('Response');
  });

  it('does not render 0 in headers table', () => {
    const text = anotherNode.find('APILogRequest').childAt(3).childAt(0).text();
    expect(text).not.toBe('0');
  });

  node.find('.APILog-copy').first().simulate('click');
});
