zoukankan      html  css  js  c++  java
  • [React Testing] Reusing test boilerplate

    Setting up a shallow renderer for each test can be redundant, especially when trying to write similar tests that have slight tweaks. In this lesson, we go over how you can reduce some of the overlapping code so that each test only contains the unique pieces of the test.

    describe('active class', ()=>{
    
        function renderLikeCounter(isActive){
            const renderer = TestUtils.createRenderer();
            renderer.render(<LikeCounter count={5} isActive={isActive}/>);
            return renderer.getRenderOutput().props.className.includes('LikeCounter--active');
        }
    
        it('should have active class based on isActive props: true', ()=>{
            expect(renderLikeCounter(true)).toEqual(true);
        });
    
        it('should have active class based on isActive props: false', ()=>{
            expect(renderLikeCounter(false)).toEqual(false);
        });
    });
  • 相关阅读:
    matlab2016b和c# .net4.0混合编程
    有限元入门
    math.net 拟合
    excel 错误提示以及其他基础知识
    excel的小bug
    Servlet体系及方法
    Servlet学习笔记
    HTTP协议
    Tomcat
    反射
  • 原文地址:https://www.cnblogs.com/Answer1215/p/5109951.html
Copyright © 2011-2022 走看看