lijianan
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
57 additions and
69 deletions
-
components/calendar/__tests__/index.test.tsx
-
components/menu/__tests__/__snapshots__/index.test.tsx.snap
-
components/menu/__tests__/index.test.tsx
-
tests/shared/rtlTest.tsx
|
|
@ -1,9 +1,9 @@ |
|
|
|
import MockDate from 'mockdate'; |
|
|
|
import Dayjs from 'dayjs'; |
|
|
|
import 'dayjs/locale/zh-cn'; |
|
|
|
import MockDate from 'mockdate'; |
|
|
|
import { type PickerPanelProps } from 'rc-picker'; |
|
|
|
import dayjsGenerateConfig from 'rc-picker/lib/generate/dayjs'; |
|
|
|
import type { Locale } from 'rc-picker/lib/interface'; |
|
|
|
import { type PickerPanelProps } from 'rc-picker'; |
|
|
|
import React from 'react'; |
|
|
|
import Calendar from '..'; |
|
|
|
import mountTest from '../../../tests/shared/mountTest'; |
|
|
@ -42,7 +42,7 @@ jest.mock('rc-picker', () => { |
|
|
|
|
|
|
|
describe('Calendar', () => { |
|
|
|
mountTest(Calendar); |
|
|
|
rtlTest(Calendar, { mockDate: true }); |
|
|
|
rtlTest(Calendar, true); |
|
|
|
|
|
|
|
function openSelect(wrapper: HTMLElement, className: string) { |
|
|
|
fireEvent.mouseDown(wrapper.querySelector(className)!.querySelector('.ant-select-selector')!); |
|
|
|
|
|
@ -329,7 +329,6 @@ exports[`Menu all types must be available in the "items" syntax 1`] = ` |
|
|
|
`; |
|
|
|
|
|
|
|
exports[`Menu rtl render component should be rendered correctly in RTL direction 1`] = ` |
|
|
|
HTMLCollection [ |
|
|
|
<ul |
|
|
|
class="ant-menu ant-menu-root ant-menu-vertical ant-menu-light ant-menu-rtl" |
|
|
|
data-menu-list="true" |
|
|
@ -381,12 +380,7 @@ HTMLCollection [ |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</li> |
|
|
|
</ul>, |
|
|
|
<div |
|
|
|
aria-hidden="true" |
|
|
|
style="display: none;" |
|
|
|
/>, |
|
|
|
] |
|
|
|
</ul> |
|
|
|
`; |
|
|
|
|
|
|
|
exports[`Menu should controlled collapse work 1`] = ` |
|
|
|
|
|
@ -5,12 +5,12 @@ import { |
|
|
|
PieChartOutlined, |
|
|
|
UserOutlined, |
|
|
|
} from '@ant-design/icons'; |
|
|
|
import React, { useState, useMemo } from 'react'; |
|
|
|
import React, { useMemo, useState } from 'react'; |
|
|
|
import type { MenuProps, MenuRef } from '..'; |
|
|
|
import Menu from '..'; |
|
|
|
import mountTest from '../../../tests/shared/mountTest'; |
|
|
|
import rtlTest from '../../../tests/shared/rtlTest'; |
|
|
|
import { fireEvent, render, act } from '../../../tests/utils'; |
|
|
|
import { act, fireEvent, render } from '../../../tests/utils'; |
|
|
|
import Layout from '../../layout'; |
|
|
|
import initCollapseMotion from '../../_util/motion'; |
|
|
|
import { noop } from '../../_util/warning'; |
|
|
@ -133,7 +133,7 @@ describe('Menu', () => { |
|
|
|
</Menu> |
|
|
|
); |
|
|
|
|
|
|
|
rtlTest(RtlDemo, { componentName: 'menu' }); |
|
|
|
rtlTest(RtlDemo); |
|
|
|
|
|
|
|
let div: HTMLDivElement; |
|
|
|
|
|
|
|
|
|
@ -1,18 +1,12 @@ |
|
|
|
import React from 'react'; |
|
|
|
import dayjs from 'dayjs'; |
|
|
|
import MockDate from 'mockdate'; |
|
|
|
import { render } from '../utils'; |
|
|
|
import React from 'react'; |
|
|
|
import ConfigProvider from '../../components/config-provider'; |
|
|
|
import { render } from '../utils'; |
|
|
|
|
|
|
|
interface TestOptions { |
|
|
|
mockDate?: boolean; |
|
|
|
componentName?: string; |
|
|
|
} |
|
|
|
|
|
|
|
function rtlTest(Component: React.ComponentType, { mockDate, componentName }: TestOptions = {}) { |
|
|
|
describe(`rtl render`, () => { |
|
|
|
it(`component should be rendered correctly in RTL direction`, () => { |
|
|
|
const isArray = componentName && ['menu'].includes(componentName); |
|
|
|
const rtlTest = (Component: React.ComponentType, mockDate = false) => { |
|
|
|
describe('rtl render', () => { |
|
|
|
it('component should be rendered correctly in RTL direction', () => { |
|
|
|
if (mockDate) { |
|
|
|
MockDate.set(dayjs('2000-09-28').valueOf()); |
|
|
|
} |
|
|
@ -21,13 +15,13 @@ function rtlTest(Component: React.ComponentType, { mockDate, componentName }: Te |
|
|
|
<Component /> |
|
|
|
</ConfigProvider>, |
|
|
|
); |
|
|
|
expect(isArray ? container.children : container.firstChild).toMatchSnapshot(); |
|
|
|
expect(container.firstChild).toMatchSnapshot(); |
|
|
|
if (mockDate) { |
|
|
|
MockDate.reset(); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// eslint-disable-next-line jest/no-export
|
|
|
|
export default rtlTest; |
|
|
|