小编Dev*_*yle的帖子

材料UI +酶测试组件

我在React中有组件,我试图用Jest测试,遗憾的是测试没有通过.

组件代码:

import React, {Component} from 'react';
import ProductItem from '../ProductItem/ProductItem';
import AppBar from "@material-ui/core/es/AppBar/AppBar";
import Tabs from "@material-ui/core/es/Tabs/Tabs";
import Tab from "@material-ui/core/es/Tab/Tab";
import {connect} from 'react-redux';


class ProductsTabsWidget extends Component {

    state = {
        value: 0
    }

    renderTabs = () => {
        return this.props.tabs.map((item, index) => {
            return item.products.length > 0 ? (<Tab key={index} label={item.title}/>) : false;
        })
    }

    handleChange = (event, value) => {
        this.setState({value});
    };


    renderConentActiveTab = () => {
        if (this.props.tabs[this.state.value]) {
            return this.props.tabs[this.state.value].products.map((productIndex) => { …
Run Code Online (Sandbox Code Playgroud)

reactjs jestjs material-ui enzyme

10
推荐指数
2
解决办法
5095
查看次数

标签 统计

enzyme ×1

jestjs ×1

material-ui ×1

reactjs ×1