Skip to content

Enhancement for test mechanism #141

Open
@chunming-c

Description

@chunming-c

@AllenFang

I have some ideas to enhance how we test. If you think it does will be better and worthy to do, I'll put it in backlog and implement in the future.

  1. render components in setup function
  2. all packages/react-bootstrap-table2 to be searched from the requiring module’s location

For topic 1, previously we rendered our components in each test case. As the more feature was implemented, the file will become longer and longer when the props is getting much more. I thought it will be better to extract common props and pass specific props by options for each test case.

for example:
before

describe('Cell', () => {
  describe('scenario 1', ... 
    beforeEach(() => {
      wrapper = shallow(<Cell row={ row } columnIndex={ 1 } rowIndex={ 1 } column={ column } />);
    })
  });

  describe('scenario 2', ...
    beforeEach(() => {
      wrapper = shallow(
        <Cell
          row={ row }
          rowIndex={ rowIndex }
          column={ column }
          columnIndex={ columnIndex }
          editable
          editMode={ Const.CLICK_TO_CELL_EDIT }
          onStart={ onStartCallBack }
        />
      );
  });
});

after

const props = { row, rowIndex, column, columnIndex };
const setup = options => shallow(<Cell { ...props } { ...options }/>);

describe('Cell', () => {
  describe('scenario 1' ...
    beforeEach(() => {
      wrapper = setup();
    })
  });

  describe('scenario 2', ...
    beforeEach(() => {
      wrapper = setup({
        editable: true,
        editMode: Const.CLICK_TO_CELL_EDIT,
        onStart: onStartCallBack
      })
  });
});

and
For topic 2, it will set alias for our packages.

before:
import SelectionCell from '../../src/row-selection/selection-cell';

after:
import SelectionCell from 'src/row-selection/selection-cell';

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions