Skip to content

Commit 46268a3

Browse files
author
梁朝飞
committed
feat: del unit
1 parent c51cf9c commit 46268a3

File tree

1 file changed

+0
-142
lines changed

1 file changed

+0
-142
lines changed

tests/index.test.tsx

Lines changed: 0 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -451,148 +451,6 @@ describe('rc-segmented', () => {
451451
offsetParentSpy.mockRestore();
452452
});
453453
});
454-
describe('Segmented vertical layout animations', () => {
455-
it('basic', () => {
456-
const offsetParentSpy = jest
457-
.spyOn(HTMLElement.prototype, 'offsetParent', 'get')
458-
.mockImplementation(() => {
459-
return container;
460-
});
461-
const handleValueChange = jest.fn();
462-
const { container, asFragment } = render(
463-
<Segmented
464-
options={['iOS', 'Android', 'Web3']}
465-
onChange={(value) => handleValueChange(value)}
466-
/>,
467-
);
468-
expect(asFragment().firstChild).toMatchSnapshot();
469-
470-
expectMatchChecked(container, [true, false, false]);
471-
expect(container.querySelectorAll('.rc-segmented-item')[0]).toHaveClass(
472-
'rc-segmented-item-selected',
473-
);
474-
475-
// >>> Click: Web3
476-
fireEvent.click(
477-
container.querySelectorAll('.rc-segmented-item-input')[2],
478-
);
479-
expect(handleValueChange).toBeCalledWith('Web3');
480-
expectMatchChecked(container, [false, false, true]);
481-
482-
expect(container.querySelectorAll('.rc-segmented-thumb')[0]).toHaveClass(
483-
'rc-segmented-thumb-motion',
484-
);
485-
486-
// thumb appeared at `iOS`
487-
exceptThumbHaveStyle(container, {
488-
'--thumb-start-top': '0px',
489-
'--thumb-start-height': '0px',
490-
});
491-
492-
// Motion => active
493-
act(() => {
494-
jest.runAllTimers();
495-
});
496-
497-
// Motion enter end
498-
fireEvent.animationEnd(container.querySelector('.rc-segmented-thumb')!);
499-
act(() => {
500-
jest.runAllTimers();
501-
});
502-
503-
// thumb should disappear
504-
expect(container.querySelector('.rc-segmented-thumb')).toBeFalsy();
505-
506-
// >>> Click: Android
507-
fireEvent.click(
508-
container.querySelectorAll('.rc-segmented-item-input')[1],
509-
);
510-
expect(handleValueChange).toBeCalledWith('Android');
511-
expectMatchChecked(container, [false, true, false]);
512-
513-
// thumb should move
514-
expect(container.querySelector('.rc-segmented-thumb')).toHaveClass(
515-
'rc-segmented-thumb-motion',
516-
);
517-
518-
// thumb appeared at `Web3`
519-
exceptThumbHaveStyle(container, {
520-
'--thumb-start-top': '180px',
521-
'--thumb-start-height': '0px',
522-
});
523-
524-
// Motion appear end
525-
act(() => {
526-
jest.runAllTimers();
527-
});
528-
exceptThumbHaveStyle(container, {
529-
'--thumb-active-top': '62px',
530-
'--thumb-active-height': '0px',
531-
});
532-
fireEvent.animationEnd(container.querySelector('.rc-segmented-thumb')!);
533-
act(() => {
534-
jest.runAllTimers();
535-
});
536-
537-
// thumb should disappear
538-
expect(container.querySelector('.rc-segmented-thumb')).toBeFalsy();
539-
540-
offsetParentSpy.mockRestore();
541-
});
542-
543-
// it('should apply correct styles on onAppearStart for vertical layout', () => {
544-
// const handleValueChange = jest.fn();
545-
// const { container } = render(
546-
// <Segmented
547-
// options={['iOS', 'Android', 'Web3']}
548-
// vertical
549-
// onChange={(value) => handleValueChange(value)}
550-
// />,
551-
// );
552-
553-
// // 模拟点击 'Android' 选项,触发垂直布局下的 onAppearStart 动画
554-
// fireEvent.click(
555-
// container.querySelectorAll('.rc-segmented-item-input')[1],
556-
// );
557-
558-
// // 验证 thumb 在垂直布局下的开始动画样式
559-
// exceptThumbHaveStyle(container, {
560-
// '--thumb-start-top': '180px',
561-
// '--thumb-start-height': '76px',
562-
// });
563-
// });
564-
565-
// it('should apply correct styles on onAppearActive for vertical layout', () => {
566-
// const handleValueChange = jest.fn();
567-
// const { container } = render(
568-
// <Segmented
569-
// options={['iOS', 'Android', 'Web3']}
570-
// vertical
571-
// onChange={(value) => handleValueChange(value)}
572-
// />,
573-
// );
574-
575-
// // 模拟点击 'iOS' 选项,触发垂直布局下的 onAppearActive 动画
576-
// fireEvent.click(
577-
// container.querySelectorAll('.rc-segmented-item-input')[0],
578-
// );
579-
580-
// // 验证 thumb 在垂直布局下的活跃动画样式
581-
// exceptThumbHaveStyle(container, {
582-
// '--thumb-active-top': '180px',
583-
// '--thumb-active-height': '76px',
584-
// });
585-
// fireEvent.animationEnd(container.querySelector('.rc-segmented-thumb')!);
586-
// act(() => {
587-
// jest.runAllTimers();
588-
// });
589-
590-
// // thumb should disappear
591-
// expect(container.querySelector('.rc-segmented-thumb')).toBeFalsy();
592-
593-
// offsetParentSpy1.mockRestore();
594-
// });
595-
});
596454

597455
it('render segmented with options null/undefined', () => {
598456
const handleValueChange = jest.fn();

0 commit comments

Comments
 (0)