Skip to content

Commit af50171

Browse files
authored
test: stable rootClassName (#394)
1 parent 81f426f commit af50171

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/preview.test.tsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,50 @@ describe('Preview', () => {
727727
expect(document.querySelector('.rc-image-preview.custom-className')).toBeTruthy();
728728
});
729729

730+
it('rootClassName on both side but classNames.root on single side', () => {
731+
const src = 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png';
732+
render(
733+
<Image
734+
src={src}
735+
rootClassName="both"
736+
classNames={{ root: 'image-root' }}
737+
styles={{
738+
root: {
739+
color: 'red',
740+
},
741+
}}
742+
preview={{
743+
open: true,
744+
classNames: {
745+
root: 'preview-root',
746+
},
747+
styles: {
748+
root: {
749+
background: 'green',
750+
},
751+
},
752+
}}
753+
/>,
754+
);
755+
756+
expect(document.querySelectorAll('.both')).toHaveLength(2);
757+
expect(document.querySelectorAll('.rc-image.image-root')).toHaveLength(1);
758+
expect(document.querySelectorAll('.rc-image-preview.preview-root')).toHaveLength(1);
759+
760+
expect(document.querySelector('.rc-image.image-root')).toHaveStyle({
761+
color: 'red',
762+
});
763+
expect(document.querySelector('.rc-image.image-root')).not.toHaveStyle({
764+
background: 'green',
765+
});
766+
expect(document.querySelector('.rc-image-preview.preview-root')).toHaveStyle({
767+
background: 'green',
768+
});
769+
expect(document.querySelector('.rc-image-preview.preview-root')).not.toHaveStyle({
770+
color: 'red',
771+
});
772+
});
773+
730774
it('if async src set should be correct', () => {
731775
const src =
732776
'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*P0S-QIRUbsUAAAAAAAAAAABkARQnAQ';

0 commit comments

Comments
 (0)