Update tests to use Enzyme 3
parent
d313e11a1f
commit
c510029923
|
@ -17,7 +17,7 @@ describe('Chip', () => {
|
|||
<span>Test</span>
|
||||
</Chip>,
|
||||
);
|
||||
const chipNode = wrapper.find('div').node;
|
||||
const chipNode = wrapper.find('div').instance();
|
||||
expect(chipNode.className).toMatch(/\bavatar-class\b/);
|
||||
});
|
||||
|
||||
|
@ -29,7 +29,7 @@ describe('Chip', () => {
|
|||
<span>Test</span>
|
||||
</TooltippedChip>,
|
||||
);
|
||||
const chipNode = wrapper.find('div').node;
|
||||
const chipNode = wrapper.find('div').instance();
|
||||
expect(chipNode.className).toMatch(/\bavatar-class\b/);
|
||||
});
|
||||
});
|
||||
|
@ -41,7 +41,7 @@ describe('Chip', () => {
|
|||
<span>Test</span>
|
||||
</Chip>,
|
||||
);
|
||||
const chipNode = wrapper.find('div').node;
|
||||
const chipNode = wrapper.find('div').instance();
|
||||
expect(chipNode.className).not.toMatch(/\bavatar-class\b/);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -27,25 +27,25 @@ describe('ProgressBar', () => {
|
|||
describe('#render', () => {
|
||||
it('renders the value and buffer bars when it is linear', () => {
|
||||
const wrapper = mount(<ProgressBar theme={theme} />);
|
||||
expect(wrapper.childAt(0).props().children.length).toEqual(2);
|
||||
expect(wrapper.childAt(0).childAt(0).props().children.length).toEqual(2);
|
||||
});
|
||||
|
||||
it('renders the value and buffer bars when it is linear', () => {
|
||||
const wrapper = mount(<ProgressBar mode="determinate" value={30} buffer={60} theme={theme} />);
|
||||
const buffer = wrapper.childAt(0).childAt(0);
|
||||
const value = wrapper.childAt(0).childAt(1);
|
||||
const buffer = wrapper.childAt(0).childAt(0).childAt(0);
|
||||
const value = wrapper.childAt(0).childAt(0).childAt(1);
|
||||
expect(buffer.props().style.transform).toEqual(`scaleX(${0.6})`);
|
||||
expect(value.props().style.transform).toEqual(`scaleX(${0.3})`);
|
||||
});
|
||||
|
||||
it('renders the svg circle when it is circular', () => {
|
||||
const wrapper = mount(<ProgressBar type="circular" theme={theme} />);
|
||||
expect(wrapper.childAt(0).props().children.type).toEqual('circle');
|
||||
expect(wrapper.childAt(0).childAt(0).props().children.type).toEqual('circle');
|
||||
});
|
||||
|
||||
it('renders the proper circle length style when it is circular and determinate', () => {
|
||||
const wrapper = mount(<ProgressBar type="circular" mode="determinate" value={30} theme={theme} />);
|
||||
const circle = wrapper.childAt(0).props().children;
|
||||
const circle = wrapper.childAt(0).childAt(0).props().children;
|
||||
const strokeLength = 2 * Math.PI * circle.props.r * 0.3;
|
||||
expect(circle.props.style.strokeDasharray).toEqual(`${strokeLength}, 400`);
|
||||
});
|
||||
|
|
|
@ -93,7 +93,7 @@ describe('Slider', () => {
|
|||
it('sets pressed state when knob is clicked', () => {
|
||||
const onChange = jest.fn();
|
||||
const wrapper = mount(<Slider min={-500} max={500} onChange={onChange} />);
|
||||
const knob = wrapper.childAt(0).childAt(0);
|
||||
const knob = wrapper.childAt(0).childAt(0).childAt(0);
|
||||
knob.simulate('mouseDown');
|
||||
expect(wrapper.state().pressed).toEqual(true);
|
||||
});
|
||||
|
@ -102,7 +102,7 @@ describe('Slider', () => {
|
|||
const onChange = jest.fn();
|
||||
const event = { touches: [{ pageX: 200 }] };
|
||||
const wrapper = mount(<Slider min={-500} max={500} onChange={onChange} />);
|
||||
const knob = wrapper.childAt(0).childAt(0);
|
||||
const knob = wrapper.childAt(0).childAt(0).childAt(0);
|
||||
knob.simulate('touchStart', event);
|
||||
expect(wrapper.state().pressed).toEqual(true);
|
||||
});
|
||||
|
@ -114,7 +114,7 @@ describe('Slider', () => {
|
|||
const instance = wrapper.instance();
|
||||
instance.setState({ sliderStart: 0, sliderLength: 1000 });
|
||||
instance.handleResize = (evt, callback) => { callback(); };
|
||||
wrapper.childAt(0).simulate('mouseDown', event);
|
||||
wrapper.childAt(0).childAt(0).simulate('mouseDown', event);
|
||||
expect(onChange).toHaveBeenCalledWith(-300);
|
||||
});
|
||||
|
||||
|
@ -125,7 +125,7 @@ describe('Slider', () => {
|
|||
const instance = wrapper.instance();
|
||||
instance.setState({ sliderStart: 0, sliderLength: 1000 });
|
||||
instance.handleResize = (evt, callback) => { callback(); };
|
||||
wrapper.childAt(0).simulate('touchStart', event);
|
||||
wrapper.childAt(0).childAt(0).simulate('touchStart', event);
|
||||
expect(onChange).toHaveBeenCalledWith(-300);
|
||||
});
|
||||
|
||||
|
@ -136,7 +136,7 @@ describe('Slider', () => {
|
|||
const instance = wrapper.instance();
|
||||
instance.setState({ sliderStart: 0, sliderLength: 1000 });
|
||||
instance.handleResize = (evt, callback) => { callback(); };
|
||||
wrapper.childAt(0).simulate('mouseDown', event);
|
||||
wrapper.childAt(0).childAt(0).simulate('mouseDown', event);
|
||||
expect(onChange).toHaveBeenCalledWith(90);
|
||||
});
|
||||
|
||||
|
@ -154,7 +154,7 @@ describe('Slider', () => {
|
|||
const onChange = jest.fn();
|
||||
const wrapper = mount(<Slider editable value={50} onChange={onChange} />);
|
||||
wrapper.instance().setState({ sliderStart: 0, sliderLength: 1000 });
|
||||
wrapper.childAt(0).simulate('mouseDown', { pageX: 900, pageY: 0 });
|
||||
wrapper.childAt(0).childAt(0).simulate('mouseDown', { pageX: 900, pageY: 0 });
|
||||
expect(onChange).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -24,21 +24,27 @@ describe('Tabs', () => {
|
|||
|
||||
it('defaults to only rendering the current tab', () => {
|
||||
const wrapper = mount(<Composition />);
|
||||
|
||||
expect(wrapper.find(TabContent).length).toEqual(1);
|
||||
expect(wrapper.find(TabContent).first().prop('tabIndex')).toEqual(0);
|
||||
|
||||
wrapper.instance().setState({ index: 1 });
|
||||
wrapper.update();
|
||||
|
||||
expect(wrapper.find(TabContent).length).toEqual(1);
|
||||
expect(wrapper.find(TabContent).first().prop('tabIndex')).toEqual(1);
|
||||
});
|
||||
|
||||
it('renders inactive tabs when hideMode is set to display', () => {
|
||||
const wrapper = mount(<Composition hideMode="display" />);
|
||||
|
||||
expect(wrapper.find(TabContent).length).toEqual(2);
|
||||
expect(wrapper.find(TabContent).at(0).prop('hidden')).toEqual(false);
|
||||
expect(wrapper.find(TabContent).at(1).prop('hidden')).toEqual(true);
|
||||
|
||||
wrapper.instance().setState({ index: 1 });
|
||||
wrapper.update();
|
||||
|
||||
expect(wrapper.find(TabContent).length).toEqual(2);
|
||||
expect(wrapper.find(TabContent).at(0).prop('hidden')).toEqual(true);
|
||||
expect(wrapper.find(TabContent).at(1).prop('hidden')).toEqual(false);
|
||||
|
|
Loading…
Reference in New Issue