小编JOH*_*ANO的帖子

自动完成 Mui 测试,模拟更改不起作用

我需要用酶模拟一个 onChange 事件来更新一个不工作的状态组件,我共享组件的代码以便得到帮助。

成分:

import React, { useState } from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
    
const top100Films = [
  { title: 'The Shawshank Redemption', year: 1994 },
  { title: 'The Godfather', year: 1972 },
  { title: 'The Godfather: Part II', year: 1974 },
];
    
const Counter = () => {
  const [value, setValue] = useState({ title: 'The Godfather', year: 1972 });

  const handleAutocomplete = (e, item) => {
    setValue(item);
  }

  return (
    <>
      {value && ( …
Run Code Online (Sandbox Code Playgroud)

testing unit-testing reactjs material-ui

8
推荐指数
1
解决办法
1372
查看次数

标签 统计

material-ui ×1

reactjs ×1

testing ×1

unit-testing ×1