Skip to content

Commit

Permalink
test: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
MadCcc committed Jul 15, 2022
1 parent 7096f9b commit 8f34fb2
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion tests/range.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ describe('Picker.Range', () => {
mock.mockRestore();
});

it('panel should be stable: right', () => {
it('panel should be stable: arrow right and panel left', () => {
const mock = spyElementPrototypes(HTMLElement, {
offsetWidth: {
get() {
Expand Down Expand Up @@ -1631,4 +1631,40 @@ describe('Picker.Range', () => {
expect(wrapper.find('.rc-picker-panel-container').getDOMNode().style.marginLeft).toBe('0px');
mock.mockRestore();
});

it('panel should be stable: arrow right and panel right', () => {
const mock = spyElementPrototypes(HTMLElement, {
offsetWidth: {
get() {
if (this.className.includes('range-arrow')) {
return 14;
} else if (this.className.includes('panel-container')) {
return 311;
} else if (this.className.includes('input')) {
return 285;
} else if (this.className.includes('range-separator')) {
return 10;
}
},
},
offsetLeft: {
get() {
if (this.className.includes('range-arrow')) {
return 305;
}
},
},
});
const wrapper = mount(
<MomentRangePicker
allowClear
defaultValue={[moment('1990-09-03'), moment('1989-11-28')]}
clearIcon={<span>X</span>}
suffixIcon={<span>O</span>}
/>,
);
wrapper.openPicker(1);
expect(wrapper.find('.rc-picker-panel-container').getDOMNode().style.marginLeft).toBe('295px');
mock.mockRestore();
});
});

0 comments on commit 8f34fb2

Please sign in to comment.