mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
refine new context API tests
This commit is contained in:
parent
c0416fc307
commit
495875792f
@ -1,8 +1,8 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import Const from '../../src/const';
|
||||
import SortCaret from '../../src/sort/caret';
|
||||
import { shallowWithContext } from '../test-helpers/new-context';
|
||||
|
||||
describe('SortCaret', () => {
|
||||
let wrapper;
|
||||
@ -10,9 +10,10 @@ describe('SortCaret', () => {
|
||||
describe('when bootstrap4 context is false', () => {
|
||||
describe(`when order prop is ${Const.SORT_ASC}`, () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<SortCaret order={ Const.SORT_ASC } />);
|
||||
const Children = wrapper.props().children({ bootstrap4: false });
|
||||
wrapper = shallow(Children);
|
||||
wrapper = shallowWithContext(
|
||||
<SortCaret order={ Const.SORT_ASC } />,
|
||||
{ bootstrap4: false }
|
||||
);
|
||||
});
|
||||
|
||||
it('should render caret correctly', () => {
|
||||
@ -25,9 +26,10 @@ describe('SortCaret', () => {
|
||||
|
||||
describe(`when order prop is ${Const.SORT_DESC}`, () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<SortCaret order={ Const.SORT_DESC } />);
|
||||
const Children = wrapper.props().children({ bootstrap4: false });
|
||||
wrapper = shallow(Children);
|
||||
wrapper = shallowWithContext(
|
||||
<SortCaret order={ Const.SORT_DESC } />,
|
||||
{ bootstrap4: false }
|
||||
);
|
||||
});
|
||||
|
||||
it('should render caret correctly', () => {
|
||||
@ -42,9 +44,7 @@ describe('SortCaret', () => {
|
||||
describe('when bootstrap4 context is true', () => {
|
||||
describe(`when order prop is ${Const.SORT_ASC}`, () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<SortCaret order={ Const.SORT_ASC } />);
|
||||
const Children = wrapper.props().children({ bootstrap4: true });
|
||||
wrapper = shallow(Children);
|
||||
wrapper = shallowWithContext(<SortCaret order={ Const.SORT_ASC } />, { bootstrap4: true });
|
||||
});
|
||||
|
||||
it('should render caret correctly', () => {
|
||||
@ -55,9 +55,7 @@ describe('SortCaret', () => {
|
||||
|
||||
describe(`when order prop is ${Const.SORT_DESC}`, () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<SortCaret order={ Const.SORT_DESC } />);
|
||||
const Children = wrapper.props().children({ bootstrap4: true });
|
||||
wrapper = shallow(Children);
|
||||
wrapper = shallowWithContext(<SortCaret order={ Const.SORT_DESC } />, { bootstrap4: true });
|
||||
});
|
||||
|
||||
it('should render caret correctly', () => {
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import { shallowWithContext } from '../test-helpers/new-context';
|
||||
import SortSymbol from '../../src/sort/symbol';
|
||||
|
||||
describe('SortSymbol', () => {
|
||||
let wrapper;
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<SortSymbol />);
|
||||
const Children = wrapper.props().children({ bootstrap4: false });
|
||||
wrapper = shallow(Children);
|
||||
wrapper = shallowWithContext(<SortSymbol />, { bootstrap4: false });
|
||||
});
|
||||
it('should render sort symbol correctly', () => {
|
||||
expect(wrapper.length).toBe(1);
|
||||
@ -20,9 +18,7 @@ describe('SortSymbol', () => {
|
||||
|
||||
describe('if bootstrap4 prop is true', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<SortSymbol />);
|
||||
const Children = wrapper.props().children({ bootstrap4: true });
|
||||
wrapper = shallow(Children);
|
||||
wrapper = shallowWithContext(<SortSymbol />, { bootstrap4: true });
|
||||
});
|
||||
it('should render sort symbol correctly', () => {
|
||||
expect(wrapper.length).toBe(1);
|
||||
|
||||
7
packages/react-bootstrap-table2/test/test-helpers/new-context.js
vendored
Normal file
7
packages/react-bootstrap-table2/test/test-helpers/new-context.js
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
export const shallowWithContext = (elem, context = {}) => {
|
||||
const wrapper = shallow(elem);
|
||||
const Children = wrapper.props().children(context);
|
||||
return shallow(Children);
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user