opened={true}
我需要测试在单击按钮后是否使用 prop 调用反应组件。我正在使用testing-library
(testing-library/react
+ testing-library/jest-dom
)。
我用类似的东西嘲笑了组件
import Component from "./path-to-file/component-name"
...
jest.mock("./path-to-file/component-name", () => {
return jest.fn().mockImplementation(() => {
return null
})
})
Run Code Online (Sandbox Code Playgroud)
我首先尝试过:
expect(Component).toBeCalledWith(expect.objectContaining({"opened": true}))
expect(Component).toHaveBeenCalledWith(expect.objectContaining({"opened": true}))
expect(Component).toHaveBeenLastCalledWith(expect.objectContaining({"opened": true}))
Run Code Online (Sandbox Code Playgroud)
但我得到了Error: expect(jest.fn()).toBeCalledWith(...expected)
。
同样的事情expect.objectContaining({"opened": expect.anything()})
甚至对于expect(Component).toBeCalledWith(expect.anything())
我也尝试过expect(ChartMenu.mock).toBeCalledWith(expect.anything())
。我遇到了不同的错误,但仍然无法工作(这次错误是Error: expect(received).toBeCalledWith(...expected)
+ Matcher error: received value must be a mock or spy function
)
谢谢您的建议!
编辑:这是我要测试的组件的简化版本:
const Component = () => {
const [chartMenuOpened, setChartMenuOpened] = useState(false)
return (
<Flex> …
Run Code Online (Sandbox Code Playgroud) 使用预输入作为单元格编辑器进行搜索、行和添加。
问题是,当应用预输入选项时,只会显示在表格内。
我试过了overflow: visible
,效果就是这样
actions-button-cell:has(.MultiColumn) {
overflow: visible;
}
.ag-cel:has(.MultiColumn)l {
overflow: visible;
}
.ag-row:has(.MultiColumn) {
z-index: 0;
}
.ag-row.ag-row-focus:has(.MultiColumn) {
z-index: 1;
}
.ag-root:has(.MultiColumn),
.ag-root-wrapper:has(.MultiColumn),
.ag-body-viewport:has(.MultiColumn),
.ag-body-viewport-wrapper:has(.MultiColumn),
.ag-center-cols-clipper:has(.MultiColumn),
.ag-center-cols-viewport:has(.MultiColumn) {
overflow: visible !important;
}
Run Code Online (Sandbox Code Playgroud)
在 css 中,这将显示选项而不隐藏,但 aggrid 行的滚动由于溢出而消失:可见。
有没有办法在 agggrid 之外显示下拉选项而不删除滚动
任何帮助将不胜感激