Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit727e2bd

Browse files
committed
Fix warning in test
1 parent9b64a14 commit727e2bd

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

‎src/Field.test.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,12 @@ describe("Field", () => {
385385
});
386386

387387
it("should pass multiple through to custom components",()=>{
388-
constCustomSelect=jest.fn(({ input})=><select{...input}/>);
388+
constCustomSelect=jest.fn(({ input})=>(
389+
<select
390+
{...input}
391+
value={input.multiple ?input.value||[] :input.value}
392+
/>
393+
));
389394
render(
390395
<Form
391396
onSubmit={onSubmitMock}

‎src/useField.test.js‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,14 @@ describe("useField", () => {
280280
const{ input}=useField(name,{
281281
subscription:{value:true},
282282
formatOnBlur,
283+
defaultValue:"",
283284
});
284285
const{ onChange, onFocus, onBlur}=input;
285286
spy(onChange,onFocus,onBlur);
286-
return<input{...input}/>;
287+
return<input{...input}value={input.value||""}/>;
287288
};
288289
const{ rerender}=render(
289-
<FormonSubmit={onSubmitMock}>
290+
<FormonSubmit={onSubmitMock}initialValues={{myField:"",dog:""}}>
290291
{()=>(
291292
<form>
292293
<MyFieldname="myField"/>
@@ -301,7 +302,7 @@ describe("useField", () => {
301302
expect(spy.mock.calls[1][2]).toBe(spy.mock.calls[0][2]);// onBlur
302303

303304
rerender(
304-
<FormonSubmit={onSubmitMock}>
305+
<FormonSubmit={onSubmitMock}initialValues={{myField:"",dog:""}}>
305306
{()=>(
306307
<form>
307308
<MyFieldname="dog"formatOnBlur/>
@@ -325,13 +326,14 @@ describe("useField", () => {
325326
const{ input}=useField(name,{
326327
subscription:{value:true},
327328
parse,
329+
defaultValue:"",
328330
});
329331
const{ onChange, onFocus, onBlur}=input;
330332
spy(onChange,onFocus,onBlur);
331-
return<input{...input}/>;
333+
return<input{...input}value={input.value||""}/>;
332334
};
333335
const{ rerender}=render(
334-
<FormonSubmit={onSubmitMock}>
336+
<FormonSubmit={onSubmitMock}initialValues={{myField:"",dog:""}}>
335337
{()=>(
336338
<form>
337339
<MyFieldname="myField"/>
@@ -346,7 +348,7 @@ describe("useField", () => {
346348
expect(spy.mock.calls[1][2]).toBe(spy.mock.calls[0][2]);// onBlur
347349

348350
rerender(
349-
<FormonSubmit={onSubmitMock}>
351+
<FormonSubmit={onSubmitMock}initialValues={{myField:"",dog:""}}>
350352
{()=>(
351353
<form>
352354
<MyFieldname="dog"parse={(x)=>x}/>
@@ -370,13 +372,14 @@ describe("useField", () => {
370372
const{ input}=useField(name,{
371373
subscription:{value:true},
372374
format,
375+
defaultValue:"",
373376
});
374377
const{ onChange, onFocus, onBlur}=input;
375378
spy(onChange,onFocus,onBlur);
376-
return<input{...input}/>;
379+
return<input{...input}value={input.value||""}/>;
377380
};
378381
const{ rerender}=render(
379-
<FormonSubmit={onSubmitMock}>
382+
<FormonSubmit={onSubmitMock}initialValues={{myField:"",dog:""}}>
380383
{()=>(
381384
<form>
382385
<MyFieldname="myField"/>
@@ -391,7 +394,7 @@ describe("useField", () => {
391394
expect(spy.mock.calls[1][2]).toBe(spy.mock.calls[0][2]);// onBlur
392395

393396
rerender(
394-
<FormonSubmit={onSubmitMock}>
397+
<FormonSubmit={onSubmitMock}initialValues={{myField:"",dog:""}}>
395398
{()=>(
396399
<form>
397400
<MyFieldname="dog"format={(x)=>x}/>
@@ -415,13 +418,14 @@ describe("useField", () => {
415418
const{ input}=useField(name,{
416419
subscription:{value:true},
417420
component,
421+
defaultValue:"",
418422
});
419423
const{ onChange, onFocus, onBlur}=input;
420424
spy(onChange,onFocus,onBlur);
421-
return<input{...input}/>;
425+
return<input{...input}value={input.value||""}/>;
422426
};
423427
const{ rerender}=render(
424-
<FormonSubmit={onSubmitMock}>
428+
<FormonSubmit={onSubmitMock}initialValues={{myField:"",dog:""}}>
425429
{()=>(
426430
<form>
427431
<MyFieldname="myField"/>
@@ -436,7 +440,7 @@ describe("useField", () => {
436440
expect(spy.mock.calls[1][2]).toBe(spy.mock.calls[0][2]);// onBlur
437441

438442
rerender(
439-
<FormonSubmit={onSubmitMock}>
443+
<FormonSubmit={onSubmitMock}initialValues={{myField:"",dog:""}}>
440444
{()=>(
441445
<form>
442446
<MyFieldname="dog"component="select"/>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp