import * as React from 'react';
import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import InitStoreWithFormula from './InitStoreWithFormula';
import { sliceBy, mockResizeObserver } from 'valor-app-utils';

configure({ adapter: new Adapter() });

mockResizeObserver();

describe('<InitStoreWithFormula/>', () => {
  it('testing', () => {
    const expectedIds = [11, 12, 13, 21, 22, 23, 31, 32, 33, 41, 42, 43, 51, 52, 53];
    const expectedValues = [20, 20, 40, 10, 10, 20, 10, 10, 20, 10, 10, 20, 30, 30, 60];

    const wrapper = mount(<InitStoreWithFormula />).find('td[id^="cell"]');
    const resultIds = wrapper
      .map(it => sliceBy(it.prop('id') as any, { from: ':' }).slice(1))
      .map(it => parseInt(it));
    const resultValues = wrapper.map(it => it.text()).map(it => parseInt(it));
    expect(resultIds).toEqual(expectedIds);
    expect(resultValues).toEqual(expectedValues);
  });
});
