diff --git a/components/result/__tests__/__snapshots__/demo.test.js.snap b/components/result/__tests__/__snapshots__/demo.test.ts.snap similarity index 100% rename from components/result/__tests__/__snapshots__/demo.test.js.snap rename to components/result/__tests__/__snapshots__/demo.test.ts.snap diff --git a/components/result/__tests__/__snapshots__/index.test.js.snap b/components/result/__tests__/__snapshots__/index.test.tsx.snap similarity index 100% rename from components/result/__tests__/__snapshots__/index.test.js.snap rename to components/result/__tests__/__snapshots__/index.test.tsx.snap diff --git a/components/result/__tests__/demo.test.js b/components/result/__tests__/demo.test.ts similarity index 100% rename from components/result/__tests__/demo.test.js rename to components/result/__tests__/demo.test.ts diff --git a/components/result/__tests__/index.test.js b/components/result/__tests__/index.test.tsx similarity index 62% rename from components/result/__tests__/index.test.js rename to components/result/__tests__/index.test.tsx index 9a9bb46aca..de27a90575 100644 --- a/components/result/__tests__/index.test.js +++ b/components/result/__tests__/index.test.tsx @@ -1,17 +1,18 @@ import React from 'react'; -import { mount } from 'enzyme'; -import { render } from '../../../tests/utils'; + import Result from '..'; import Button from '../../button'; + import mountTest from '../../../tests/shared/mountTest'; import rtlTest from '../../../tests/shared/rtlTest'; +import { render } from '../../../tests/utils'; describe('Result', () => { mountTest(Result); rtlTest(Result); it('🙂 successPercent should decide the progress status when it exists', () => { - const wrapper = mount( + const { container: wrapper } = render( { ]} />, ); - expect(wrapper.find('.anticon-check-circle')).toHaveLength(1); + expect(wrapper.querySelectorAll('.anticon-check-circle')).toHaveLength(1); }); it('🙂 different status, different class', () => { - const wrapper = mount(); - expect(wrapper.find('.ant-result-warning')).toHaveLength(1); + const { container: wrapper, rerender } = render(); + expect(wrapper.querySelectorAll('.ant-result-warning')).toHaveLength(1); - wrapper.setProps({ - status: 'error', - }); + rerender(); - expect(wrapper.find('.ant-result-error')).toHaveLength(1); + expect(wrapper.querySelectorAll('.ant-result-error')).toHaveLength(1); - wrapper.setProps({ - status: '500', - }); + rerender(); - expect(wrapper.find('.ant-result-500')).toHaveLength(1); + expect(wrapper.querySelectorAll('.ant-result-500')).toHaveLength(1); }); it('🙂 When status = 404, the icon is an image', () => { - const wrapper = mount(); - expect(wrapper.find('.ant-result-404 .ant-result-image')).toHaveLength(1); + const { container: wrapper } = render(); + expect(wrapper.querySelectorAll('.ant-result-404 .ant-result-image')).toHaveLength(1); }); it('🙂 When extra is undefined, the extra dom is undefined', () => { - const wrapper = mount(); - expect(wrapper.find('.ant-result-extra')).toHaveLength(0); + const { container: wrapper } = render(); + expect(wrapper.querySelectorAll('.ant-result-extra')).toHaveLength(0); }); it('🙂 result should support className', () => { - const wrapper = mount(); - expect(wrapper.find('.ant-result.my-result')).toHaveLength(1); + const { container: wrapper } = render( + , + ); + expect(wrapper.querySelectorAll('.ant-result.my-result')).toHaveLength(1); }); it('should warning when pass a string as icon props', () => {