Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions components/input/__tests__/input-926.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { mount } from '@vue/test-utils';
import { readFileSync } from 'fs';
import { resolve } from 'path';

import getPrefixCls from '../../_util/getPrefixCls';
import Input from '../input.vue';

const prefixCls = getPrefixCls('input');
const inputInnerPrefixCls = getPrefixCls('input-inner');

function getInputInnerLess(): string {
return readFileSync(
resolve(__dirname, '../style/inputInner.less'),
'utf-8',
);
}

test('inputInner.less has vertical-align: middle for both prefix and suffix', () => {
const lessContent = getInputInnerLess();
const prefixMatch = lessContent.match(/&\-prefix\s*\{[^}]*vertical-align\s*:\s*middle/);
const suffixMatch = lessContent.match(/&\-suffix\s*\{[^}]*vertical-align\s*:\s*middle/);
expect(prefixMatch).not.toBeNull();
expect(suffixMatch).not.toBeNull();
});

test('FInput with prefix and suffix slots mounts without error', () => {
expect(() =>
mount(Input, {
props: {
modelValue: 'test',
},
slots: {
prefix: 'PREFIX',
suffix: 'SUFFIX',
},
}),
).not.toThrow();
const wrapper = mount(Input, {
props: {
modelValue: '',
},
slots: {
prefix: 'PREFIX',
suffix: 'SUFFIX',
},
});
expect(wrapper.find(`.${inputInnerPrefixCls}-prefix`).exists()).toBe(true);
expect(wrapper.find(`.${inputInnerPrefixCls}-suffix`).exists()).toBe(true);
});
3 changes: 2 additions & 1 deletion components/input/style/inputInner.less
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@
}
&-prefix {
margin-right: 8px;
vertical-align: middle;
}

&-suffix {
margin-left: 8px;
vertical-align: bottom;
vertical-align: middle;
}

&-icon {
Expand Down
Loading