Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: input融合form,icon使用修改 #1970

Merged
merged 17 commits into from
Dec 23, 2022
4 changes: 2 additions & 2 deletions src/packages/__VUE/form/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
required
:rules="[{ required: true, message: translate('nameTip') }]"
>
<input
<nut-input
class="nut-input-text"
v-model="dynamicForm.state.name"
:placeholder="translate('nameTip')"
Expand Down Expand Up @@ -75,7 +75,7 @@
required
:rules="[{ required: true, message: translate('nameTip') }]"
>
<input
<nut-input
class="nut-input-text"
@blur="customBlurValidate('name')"
v-model="formData.name"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`should colon 1`] = `
"<view class=\\"nut-input__label\\" style=\\"width: 80px; text-align: left;\\">
<view class=\\"nut-input__label-string\\">test :</view>
</view>"
`;

exports[`should render word limit correctly 1`] = `"<view class=\\"nut-input-word-limit\\"><span class=\\"nut-input-word-num\\">3</span>/9999</view>"`;

exports[`should render word limit correctly when modelValue is null 1`] = `
"<view class=\\"nut-input nut-input--border\\" maxlength=\\"3\\">
<!--v-if-->
<!--v-if-->
<view class=\\"nut-input-value\\">
<view class=\\"nut-input-inner\\">
<view class=\\"nut-input-box\\"><input style=\\"text-align: left;\\" type=\\"text\\" class=\\"input-text\\" maxlength=\\"9999\\" placeholder=\\"\\" formattrigger=\\"onChange\\" enterkeyhint=\\"done\\"></view>
<view class=\\"nut-input-clear-box\\">
<!--v-if-->
<view class=\\"nut-input-box\\"><input style=\\"text-align: left;\\" type=\\"text\\" class=\\"input-text\\" maxlength=\\"9999\\" placeholder=\\"\\" formattrigger=\\"onChange\\" enterkeyhint=\\"done\\">
<view class=\\"nut-input-word-limit\\"><span class=\\"nut-input-word-num\\">0</span>/9999</view>
</view>
<!--v-if-->
<!--v-if-->
<!--v-if-->
</view>
<view class=\\"nut-input-word-limit\\"><span class=\\"nut-input-word-num\\">0</span>/9999</view>
<!--v-if-->
</view>
</view>"
`;
54 changes: 2 additions & 52 deletions src/packages/__VUE/input/__tests__/input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ afterAll(() => {
});

test('base', () => {
const wrapper = mount(Input, { props: { modelValue: 3 } });
const wrapper = mount(Input, { props: { modelValue: '3' } });
const input = wrapper.find('input');
expect(input.exists()).toBe(true);
expect(input.element.value).toBe('3');
Expand Down Expand Up @@ -102,53 +102,14 @@ test('should format input value when type is digit', () => {
// expect((wrapper.emitted('change') as any)[1][0]).toEqual('11');
});

test('should no label', () => {
const wrapper = mount(Input, {
props: {}
});
const label = wrapper.find('.label-string');
expect(label.exists()).toBe(false);
});

test('should label', () => {
const wrapper = mount(Input, {
props: {
label: '文本'
}
});
const label = wrapper.find('.label-string');
expect(label.text()).toBe('文本');
});

test('should label-class', () => {
const wrapper = mount(Input, {
props: {
label: '文本',
labelClass: 'test-class'
}
});
const label = wrapper.find('.nut-input__label');
expect(label.classes()).toContain('test-class');
});

test('should colon', () => {
const wrapper = mount(Input, {
props: {
label: 'test',
colon: true
}
});
expect(wrapper.find('.nut-input__label').html()).toMatchSnapshot();
});

test('should require', () => {
const wrapper = mount(Input, {
props: {
required: true
}
});
const input = wrapper.find('.nut-input');
expect(input.classes()).toContain('nut-input-required');
expect(input.classes()).toContain('nut-input--required');
});

test('should disabled', () => {
Expand Down Expand Up @@ -193,17 +154,6 @@ test('should render word limit correctly when modelValue is null', () => {
expect(wrapper.html()).toMatchSnapshot();
});

test('should labelAlign', () => {
const wrapper = mount(Input, {
props: {
label: '文本',
labelAlign: 'right'
}
});
const input: any = wrapper.find('.nut-input__label');
expect(input.element.style.textAlign).toEqual('right');
});

test('should inputAlign', () => {
const wrapper = mount(Input, {
props: {
Expand Down
Loading