@@ -18,6 +18,8 @@ const leftIconPositionClass = searchNs.m('left');
1818const rightIconPositionClass = searchNs . m ( 'right' ) ;
1919const noBorderClass = searchNs . m ( 'no-border' ) ;
2020
21+ const dotInputNs = useNamespace ( 'input' , true ) ;
22+
2123describe ( '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