{"size": 1782, "ext": "js", "max_stars_repo_path": "src/components/Pair/Hero/OrderBookWidget/OrderBookWidget.test.js", "max_stars_repo_name": "cyril-march/zingBitt", "max_stars_repo_stars_event_min_datetime": "2017-09-01T06:33:59.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-28T03:19:39.000Z", "max_issues_repo_path": "src/components/Pair/Hero/OrderBookWidget/OrderBookWidget.test.js", "max_issues_repo_name": "cyril-march/zingBitt", "max_issues_repo_issues_event_min_datetime": "2017-08-16T12:42:06.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-11T12:12:05.000Z", "max_forks_repo_path": "src/components/Pair/Hero/OrderBookWidget/OrderBookWidget.test.js", "max_forks_repo_name": "cyril-march/zingBitt", "max_forks_repo_forks_event_min_datetime": "2017-09-01T09:45:47.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-17T09:58:41.000Z"}
{"max_stars_count": 155, "max_issues_count": 148, "max_forks_count": 287, "avg_line_length": 40.5, "max_line_length": 122, "alphanum_fraction": 0.6806958474}
import React from 'react';
import { shallow } from 'enzyme';
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import OrderBookWidget from './OrderBookWidget.js';
import CoinSelector from '../ExchangeWidget/CoinInput/CoinSelector/CoinSelector';

const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);

describe('OrderBookWidget', () => {
  const initialState = {
    wallet: { address: '', valid: false, show: false },
    selectedCoin: { deposit: 'OMG', receive: 'ETH', prev: { deposit: 'OMG', receive: 'ETH' }, lastSelected: 'deposit' },
    price: { pair: 'ETHOMG', deposit: 101, receive: 1.76250023, lastEdited: 'deposit' },
    error: { show: false, type: 'INVALID_AMOUNT' },
    orderBook: { order_type: 'BUY', quantity: '', limit_rate: '', sellDepth: [], buyDepth: [], history: [], myOrders: [],}
  };
  let store, wrapShallow;

  beforeEach(() => {
    store = mockStore(initialState);
    wrapShallow = shallow(<OrderBookWidget store={store} />).dive().dive();
  });

  it('renders correctly', () => {
    expect(wrapShallow).toMatchSnapshot();
  });

  it('contains CoinInput, WalletAddress, LimitForm, OrderDepth, MyOrders, button ', () => {
    expect(wrapShallow.find(CoinSelector).length).toBe(2);
    expect(wrapShallow.find('Connect(WalletAddress)').length).toBe(1);
    expect(wrapShallow.find('Connect(LimitOrderForm)').length).toBe(1);
    expect(wrapShallow.find('Connect(OrderDepth)').length).toBe(1);
    expect(wrapShallow.find('Connect(MyOrders)').length).toBe(1);
    expect(wrapShallow.find('button').length).toBe(1);
  });

  it('submit button changes on wallet shown', () => {
    expect(wrapShallow.find('button').text()).toEqual('orderbookwidget.buy ETH orderbookwidget.with OMG');
  });
});

