Skip to content

Commit 6329a71

Browse files
hxj9102kagol
authored andcommitted
test(search): improve test case
1 parent e70625f commit 6329a71

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

packages/devui-vue/devui/search/__tests__/search.spec.ts

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const leftIconPositionClass = searchNs.m('left');
1818
const rightIconPositionClass = searchNs.m('right');
1919
const noBorderClass = searchNs.m('no-border');
2020

21+
const dotInputNs = useNamespace('input', true);
22+
2123
describe('search test', () => {
2224
it('should render correctly', async () => {
2325
const value = ref('test');
@@ -279,13 +281,49 @@ describe('search test', () => {
279281
wrapper.unmount();
280282
});
281283

282-
it.todo('props placeholder should work well.');
284+
it('props placeholder should work well.', async () => {
285+
const wrapper = mount({
286+
components: { DSearch },
287+
template: `
288+
<d-search
289+
placeholder="请输入"
290+
></d-search>
291+
`,
292+
});
283293

284-
it.todo('props auto-focus should work well.');
294+
expect(wrapper.find(dotInputNs.e('inner')).attributes('placeholder')).toBe('请输入');
295+
wrapper.unmount();
296+
});
297+
298+
it('props auto-focus should work well.', async () => {
299+
const wrapper = mount({
300+
components: { DSearch },
301+
template: `
302+
<d-search
303+
auto-focus
304+
></d-search>
305+
`,
306+
});
307+
308+
expect(wrapper.find(dotInputNs.e('inner')).attributes('autofocus')).toBe('true');
309+
wrapper.unmount();
310+
});
285311

286312
it.todo('props is-keyup-search should work well.');
287313

288314
it.todo('props delay should work well.');
289315

290-
it.todo('props max-length should work well.');
316+
it('props max-length should work well.', async () => {
317+
const wrapper = mount({
318+
components: { DSearch },
319+
template: `
320+
<d-search
321+
:max-length="5"
322+
></d-search>
323+
`,
324+
});
325+
326+
expect(wrapper.find(dotInputNs.e('inner')).attributes('maxlength')).toBe('5');
327+
wrapper.unmount();
328+
});
291329
});

0 commit comments

Comments
 (0)