fix: unit test
parent
01096b556d
commit
8eb6afb9b0
|
@ -42,7 +42,7 @@ const responsiveObserve = {
|
|||
if (!subscribers.size) this.unregister();
|
||||
},
|
||||
unregister() {
|
||||
Object.keys(responsiveMap).forEach((screen: Breakpoint) => {
|
||||
Object.keys(responsiveMap).forEach((screen: string) => {
|
||||
const matchMediaQuery = responsiveMap[screen]!;
|
||||
const handler = this.matchHandlers[matchMediaQuery];
|
||||
handler?.mql.removeListener(handler?.listener);
|
||||
|
@ -50,7 +50,7 @@ const responsiveObserve = {
|
|||
subscribers.clear();
|
||||
},
|
||||
register() {
|
||||
Object.keys(responsiveMap).forEach((screen: Breakpoint) => {
|
||||
Object.keys(responsiveMap).forEach((screen: string) => {
|
||||
const matchMediaQuery = responsiveMap[screen]!;
|
||||
const listener = ({ matches }: { matches: boolean }) => {
|
||||
this.dispatch({
|
||||
|
|
|
@ -19,18 +19,11 @@ const AffixMounter = {
|
|||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<div ref="container" class="container">
|
||||
<Affix
|
||||
class="fixed"
|
||||
target={() => this.$refs.container}
|
||||
ref="affix"
|
||||
{...{ props: this.$props }}
|
||||
>
|
||||
<Affix class="fixed" target={() => this.$refs.container} ref="affix">
|
||||
<Button type="primary">Fixed at the top of container</Button>
|
||||
</Affix>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -140,6 +140,6 @@ AutoComplete.install = function(app: App) {
|
|||
};
|
||||
|
||||
export default AutoComplete as typeof AutoComplete & {
|
||||
readonly Option: typeof AutoComplete.Option;
|
||||
readonly OptGroup: typeof AutoComplete.OptGroup;
|
||||
readonly Option: typeof Option;
|
||||
readonly OptGroup: typeof OptGroup;
|
||||
};
|
||||
|
|
|
@ -59,7 +59,7 @@ exports[`Button should not render as link button when href is undefined 1`] = `
|
|||
`;
|
||||
|
||||
exports[`Button should support link button 1`] = `
|
||||
<a target="_blank" href="http://ant.design" class="ant-btn">
|
||||
<a target="_blank" class="ant-btn" href="http://ant.design">
|
||||
<!----><span>link button</span>
|
||||
</a>
|
||||
`;
|
||||
|
|
|
@ -96,7 +96,7 @@ const Card = defineComponent({
|
|||
} = this.$props;
|
||||
const { $slots } = this;
|
||||
const children = getSlot(this);
|
||||
const getPrefixCls = this.configProvider.getPrefixCls;
|
||||
const { getPrefixCls } = this.configProvider;
|
||||
const prefixCls = getPrefixCls('card', customizePrefixCls);
|
||||
|
||||
const tabBarExtraContent = getComponent(this, 'tabBarExtraContent');
|
||||
|
|
|
@ -48,7 +48,7 @@ export default defineComponent({
|
|||
},
|
||||
methods: {
|
||||
getOptions() {
|
||||
const { options, $slots } = this;
|
||||
const { options = [], $slots } = this;
|
||||
return options.map(option => {
|
||||
if (typeof option === 'string') {
|
||||
return {
|
||||
|
|
|
@ -8,11 +8,11 @@ describe('ConfigProvider', () => {
|
|||
mountTest({
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<>
|
||||
<ConfigProvider>
|
||||
<div />
|
||||
</ConfigProvider>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -89,16 +89,16 @@ const ACol = defineComponent<ColProps>({
|
|||
let mergedStyle: CSSProperties = {};
|
||||
if (gutter) {
|
||||
mergedStyle = {
|
||||
...(gutter[0]! > 0
|
||||
...(gutter[0] > 0
|
||||
? {
|
||||
paddingLeft: gutter[0]! / 2,
|
||||
paddingRight: gutter[0]! / 2,
|
||||
paddingLeft: `${gutter[0] / 2}px`,
|
||||
paddingRight: `${gutter[0] / 2}px`,
|
||||
}
|
||||
: {}),
|
||||
...(gutter[1]! > 0
|
||||
...(gutter[1] > 0
|
||||
? {
|
||||
paddingTop: gutter[1]! / 2,
|
||||
paddingBottom: gutter[1]! / 2,
|
||||
paddingTop: `${gutter[1] / 2}px`,
|
||||
paddingBottom: `${gutter[1] / 2}px`,
|
||||
}
|
||||
: {}),
|
||||
...mergedStyle,
|
||||
|
@ -109,7 +109,7 @@ const ACol = defineComponent<ColProps>({
|
|||
}
|
||||
|
||||
return (
|
||||
<div style={mergedStyle} class={classes}>
|
||||
<div class={classes} style={mergedStyle}>
|
||||
{slots.default?.()}
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -104,16 +104,16 @@ const ARow = defineComponent<RowProps>({
|
|||
[`${prefixCls}-${align}`]: align,
|
||||
});
|
||||
const rowStyle = {
|
||||
...(gutter[0]! > 0
|
||||
...(gutter[0] > 0
|
||||
? {
|
||||
marginLeft: gutter[0]! / -2,
|
||||
marginRight: gutter[0]! / -2,
|
||||
marginLeft: `${gutter[0] / -2}px`,
|
||||
marginRight: `${gutter[0] / -2}px`,
|
||||
}
|
||||
: {}),
|
||||
...(gutter[1]! > 0
|
||||
...(gutter[1] > 0
|
||||
? {
|
||||
marginTop: gutter[1]! / -2,
|
||||
marginBottom: gutter[1]! / 2,
|
||||
marginTop: `${gutter[1] / -2}px`,
|
||||
marginBottom: `${gutter[1] / -2}px`,
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
|
|
|
@ -3,12 +3,24 @@
|
|||
exports[`Grid renders wrapped Col correctly 1`] = `
|
||||
<div class="ant-row" style="margin-left: -10px; margin-right: -10px;">
|
||||
<div>
|
||||
<div class="ant-col ant-col-12" style="padding-left: 10px; padding-right: 10px;"></div>
|
||||
<div class="ant-col ant-col-12" style="padding-left: 10px; padding-right: 10px;">
|
||||
<!---->
|
||||
</div>
|
||||
</div>
|
||||
<div class="ant-col ant-col-12" style="padding-left: 10px; padding-right: 10px;">
|
||||
<!---->
|
||||
</div>
|
||||
<div class="ant-col ant-col-12" style="padding-left: 10px; padding-right: 10px;"></div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Grid should render Col 1`] = `<div class="ant-col ant-col-2"></div>`;
|
||||
exports[`Grid should render Col 1`] = `
|
||||
<div class="ant-col ant-col-2">
|
||||
<!---->
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`Grid should render Row 1`] = `<div class="ant-row"></div>`;
|
||||
exports[`Grid should render Row 1`] = `
|
||||
<div class="ant-row">
|
||||
<!---->
|
||||
</div>
|
||||
`;
|
||||
|
|
|
@ -31,26 +31,29 @@ export interface InternalSelectProps<VT> extends Omit<RcSelectProps<VT>, 'mode'>
|
|||
}
|
||||
|
||||
export interface SelectPropsTypes<VT>
|
||||
extends Omit<InternalSelectProps<VT>, 'inputIcon' | 'mode' | 'getInputElement' | 'backfill' | 'class' | 'style'> {
|
||||
extends Omit<
|
||||
InternalSelectProps<VT>,
|
||||
'inputIcon' | 'mode' | 'getInputElement' | 'backfill' | 'class' | 'style'
|
||||
> {
|
||||
mode?: 'multiple' | 'tags';
|
||||
}
|
||||
export type SelectTypes = SelectPropsTypes<SelectValue>
|
||||
export type SelectTypes = SelectPropsTypes<SelectValue>;
|
||||
export const SelectProps = {
|
||||
...omit(props, ['inputIcon', 'mode', 'getInputElement', 'backfill', 'class', 'style']),
|
||||
value: {
|
||||
type: [Array, Object, String, Number] as PropType<SelectValue>
|
||||
type: [Array, Object, String, Number] as PropType<SelectValue>,
|
||||
},
|
||||
defaultValue: {
|
||||
type: [Array, Object, String, Number] as PropType<SelectValue>
|
||||
type: [Array, Object, String, Number] as PropType<SelectValue>,
|
||||
},
|
||||
suffixIcon: PropTypes.VNodeChild,
|
||||
itemIcon: PropTypes.VNodeChild,
|
||||
size: PropTypes.oneOf(tuple('small', 'middle', 'large', undefined, 'default')),
|
||||
mode: PropTypes.oneOf(tuple('multiple', 'tags')),
|
||||
mode: PropTypes.oneOf(tuple('multiple', 'tags', 'SECRET_COMBOBOX_MODE_DO_NOT_USE')),
|
||||
bordered: PropTypes.looseBool.def(true),
|
||||
transitionName: PropTypes.string.def('slide-up'),
|
||||
choiceTransitionName: PropTypes.string.def(''),
|
||||
}
|
||||
};
|
||||
|
||||
const Select = defineComponent({
|
||||
name: 'ASelect',
|
||||
|
@ -78,7 +81,7 @@ const Select = defineComponent({
|
|||
};
|
||||
|
||||
const mode = computed(() => {
|
||||
const { mode } = props
|
||||
const { mode } = props;
|
||||
|
||||
if ((mode as any) === 'combobox') {
|
||||
return undefined;
|
||||
|
@ -91,7 +94,8 @@ const Select = defineComponent({
|
|||
return mode;
|
||||
});
|
||||
|
||||
const mergedClassName = computed(()=> classNames(
|
||||
const mergedClassName = computed(() =>
|
||||
classNames(
|
||||
{
|
||||
[`${props.prefixCls}-lg`]: props.size === 'large',
|
||||
[`${props.prefixCls}-sm`]: props.size === 'small',
|
||||
|
@ -99,24 +103,32 @@ const Select = defineComponent({
|
|||
[`${props.prefixCls}-borderless`]: !props.bordered,
|
||||
},
|
||||
attrs.class,
|
||||
));
|
||||
),
|
||||
);
|
||||
const triggerChange = (...args: any[]) => {
|
||||
console.log(args)
|
||||
emit('update:value', ...args)
|
||||
emit('change', ...args)
|
||||
}
|
||||
console.log(args);
|
||||
emit('update:value', ...args);
|
||||
emit('change', ...args);
|
||||
};
|
||||
return {
|
||||
mergedClassName,
|
||||
mode,
|
||||
focus,
|
||||
blur,
|
||||
configProvider,
|
||||
triggerChange
|
||||
}
|
||||
triggerChange,
|
||||
};
|
||||
},
|
||||
render() {
|
||||
const {configProvider, mode, mergedClassName,triggerChange, $slots: slots, $props} = this as any;
|
||||
const props: SelectTypes = $props
|
||||
const {
|
||||
configProvider,
|
||||
mode,
|
||||
mergedClassName,
|
||||
triggerChange,
|
||||
$slots: slots,
|
||||
$props,
|
||||
} = this as any;
|
||||
const props: SelectTypes = $props;
|
||||
const {
|
||||
prefixCls: customizePrefixCls,
|
||||
notFoundContent,
|
||||
|
@ -126,10 +138,14 @@ const Select = defineComponent({
|
|||
dropdownClassName,
|
||||
direction,
|
||||
virtual,
|
||||
dropdownMatchSelectWidth
|
||||
dropdownMatchSelectWidth,
|
||||
} = props;
|
||||
|
||||
const { getPrefixCls, renderEmpty, getPopupContainer: getContextPopupContainer } = configProvider
|
||||
const {
|
||||
getPrefixCls,
|
||||
renderEmpty,
|
||||
getPopupContainer: getContextPopupContainer,
|
||||
} = configProvider;
|
||||
const prefixCls = getPrefixCls('select', customizePrefixCls);
|
||||
|
||||
const isMultiple = mode === 'multiple' || mode === 'tags';
|
||||
|
@ -139,7 +155,7 @@ const Select = defineComponent({
|
|||
if (notFoundContent !== undefined) {
|
||||
mergedNotFound = notFoundContent;
|
||||
} else if (slots.notFoundContent) {
|
||||
mergedNotFound = slots.notFoundContent()
|
||||
mergedNotFound = slots.notFoundContent();
|
||||
} else if (mode === 'combobox') {
|
||||
mergedNotFound = null;
|
||||
} else {
|
||||
|
@ -147,11 +163,14 @@ const Select = defineComponent({
|
|||
}
|
||||
|
||||
// ===================== Icons =====================
|
||||
const { suffixIcon, itemIcon, removeIcon, clearIcon } = getIcons({
|
||||
const { suffixIcon, itemIcon, removeIcon, clearIcon } = getIcons(
|
||||
{
|
||||
...this.$props,
|
||||
multiple: isMultiple,
|
||||
prefixCls,
|
||||
}, slots);
|
||||
},
|
||||
slots,
|
||||
);
|
||||
|
||||
const selectProps = omit(props, [
|
||||
'prefixCls',
|
||||
|
@ -187,9 +206,9 @@ const Select = defineComponent({
|
|||
onChange={triggerChange}
|
||||
>
|
||||
{slots?.default()}
|
||||
</RcSelect>
|
||||
}
|
||||
})
|
||||
</RcSelect>;
|
||||
},
|
||||
});
|
||||
/* istanbul ignore next */
|
||||
Select.install = function(app: App) {
|
||||
app.component(Select.name, Select);
|
||||
|
|
|
@ -73,7 +73,6 @@ export const props = {
|
|||
|
||||
// Options
|
||||
options: PropTypes.array,
|
||||
children: PropTypes.array.def([]),
|
||||
mode: PropTypes.string,
|
||||
|
||||
// Value
|
||||
|
@ -163,7 +162,7 @@ export const props = {
|
|||
* Do not use in production environment.
|
||||
*/
|
||||
internalProps: PropTypes.object.def({}),
|
||||
}
|
||||
};
|
||||
|
||||
export interface SelectProps<OptionsType extends object[], ValueType> {
|
||||
prefixCls?: string;
|
||||
|
|
Loading…
Reference in New Issue