首页 > 其他分享 >单元测试

单元测试

时间:2023-10-25 12:08:01浏览次数:34  
标签:show 单元测试 label width prop true 78

 

 

/*
 * @Author: yeminglong
 * @Date: 2023-09-09 10:23:30
 * @LastEditTime: 2023-09-09 14:51:52
 * @LastEditors: yeminglong
 * @Description: 
 */


/**
 * tree2Array
 * @param {tree} tree 
 * @returns 
 */
export function treeToArray(tree) {
    let res = [];
    for (const item of tree) {
        const { children, ...i } = item;
        if (children && children.length) {
            res = res.concat(treeToArray(children));
        }
        res.push(i);
    }
    return res;
}

const columns = [
    {
        label: '监控时间',
        prop: 'data_time',
        show: true,
        width: '150',
    },
    {
        label: '生产设施工况标记',
        prop: 'workcordSc',
        show: false,
        width: '120',
        align: 'center',
        children: [
            {
                label: '自动',
                prop: 'zd_workcordSc',
                show: true,
                width: '85',
            },
            {
                label: '人工',
                prop: 'rg_workcordSc',
                show: true,
                width: '85',
            },
        ],
    },
    {
        label: '流量',
        prop: 'B01',
        show: true,
        width: '78',
        children: [
            {
                label: '瞬时流量(升/秒)',
                prop: 'avg_value_B01',
                show: false,
                width: '110',
            },
            {
                label: '累计流量(立方米)',
                prop: 'cou_value_B01',
                show: true,
                width: '110',
            },
            {
                label: '自动监测设备维护标记',
                prop: 'flag_B01',
                show: true,
                width: '120',
                children: [
                    {
                        label: '自动',
                        prop: 'zd_flag_B01',
                        show: true,
                        width: '85',
                    },
                    {
                        label: '人工',
                        prop: 'rg_flag_B01',
                        show: true,
                        width: '85',
                    },
                ],
            },
        ],
    },
    {
        label: 'pH',
        prop: '001',
        show: true,
        width: '78',
        children: [
            {
                label: '监测值',
                prop: 'sbz_001',
                show: true,
                width: '78',
                children: [
                    {
                        label: '最小值',
                        prop: 'min_value_001',
                        show: true,
                        width: '78',
                    },
                    {
                        label: '平均值',
                        prop: 'avg_value_001',
                        show: true,
                        width: '78',
                    },
                    {
                        label: '最大值',
                        prop: 'max_value_001',
                        show: true,
                        width: '78',
                    },
                ],
            },
            {
                label: '标准值',
                prop: 'outlet_standard_001',
                show: true,
                width: '75',
            },
            {
                label: '自动监测设备维护标记',
                prop: 'flag_001',
                show: true,
                width: '120',
                children: [
                    {
                        label: '自动',
                        prop: 'zd_flag_001',
                        show: true,
                        width: '85',
                    },
                    {
                        label: '人工',
                        prop: 'rg_flag_001',
                        show: true,
                        width: '85',
                    },
                ],
            },
        ],
    },
    {
        label: '化学需氧量(毫克/升)',
        prop: '011',
        show: true,
        width: '78',
        children: [
            {
                label: '上报值',
                prop: 'yuanshi_011',
                show: true,
                width: '78',
                children: [
                    {
                        label: '浓度',
                        prop: 'avg_value_011',
                        show: true,
                        width: '78',
                    },
                    {
                        label: '最小值',
                        prop: 'min_value_011',
                        show: false,
                        width: '78',
                    },
                    {
                        label: '最大值',
                        prop: 'max_value_011',
                        show: false,
                        width: '78',
                    },
                    {
                        label: '标准值',
                        prop: 'outlet_standard_011',
                        show: true,
                        width: '75',
                    },
                    {
                        label: '排放量(千克)',
                        prop: 'cou_value_011',
                        show: true,
                        width: '85',
                    },
                    {
                        label: '自动监测设备维护标记',
                        prop: 'flag_011',
                        show: true,
                        width: '120',
                        children: [
                            {
                                label: '自动',
                                prop: 'zd_flag_011',
                                show: true,
                                width: '85',
                            },
                            {
                                label: '人工',
                                prop: 'rg_flag_011',
                                show: true,
                                width: '85',
                            },
                        ],
                    },
                ],
            },
            {
                label: '修正值',
                prop: 'xiuzhen_011',
                show: true,
                width: '78',
                children: [
                    {
                        label: '浓度值',
                        prop: 'avg_revised_011',
                        show: true,
                        width: '78',
                    },
                    {
                        label: '排放量(千克)',
                        prop: 'cou_revised_011',
                        show: true,
                        width: '85',
                    },
                ],
            },
        ],
    },
    {
        label: '氨氮(毫克/升)',
        prop: '060',
        show: true,
        width: '78',
        children: [
            {
                label: '上报值',
                prop: 'yuanshi_060',
                show: true,
                width: '78',
                children: [
                    {
                        label: '浓度',
                        prop: 'avg_value_060',
                        show: true,
                        width: '78',
                    },
                    {
                        label: '最小值',
                        prop: 'min_value_060',
                        show: false,
                        width: '78',
                    },
                    {
                        label: '最大值',
                        prop: 'max_value_060',
                        show: false,
                        width: '78',
                    },
                    {
                        label: '标准值',
                        prop: 'outlet_standard_060',
                        show: true,
                        width: '75',
                    },
                    {
                        label: '排放量(千克)',
                        prop: 'cou_value_060',
                        show: true,
                        width: '85',
                    },
                    {
                        label: '自动监测设备维护标记',
                        prop: 'flag_060',
                        show: true,
                        width: '120',
                        children: [
                            {
                                label: '自动',
                                prop: 'zd_flag_060',
                                show: true,
                                width: '85',
                            },
                            {
                                label: '人工',
                                prop: 'rg_flag_060',
                                show: true,
                                width: '85',
                            },
                        ],
                    },
                ],
            },
            {
                label: '修正值',
                prop: 'xiuzhen_060',
                show: true,
                width: '78',
                children: [
                    {
                        label: '浓度值',
                        prop: 'avg_revised_060',
                        show: true,
                        width: '78',
                    },
                    {
                        label: '排放量(千克)',
                        prop: 'cou_revised_060',
                        show: true,
                        width: '85',
                    },
                ],
            },
        ],
    },
    {
        label: '总氮(毫克/升)',
        prop: '065',
        show: true,
        width: '78',
        children: [
            {
                label: '上报值',
                prop: 'yuanshi_065',
                show: true,
                width: '78',
                children: [
                    {
                        label: '浓度',
                        prop: 'avg_value_065',
                        show: true,
                        width: '78',
                    },
                    {
                        label: '最小值',
                        prop: 'min_value_065',
                        show: false,
                        width: '78',
                    },
                    {
                        label: '最大值',
                        prop: 'max_value_065',
                        show: false,
                        width: '78',
                    },
                    {
                        label: '标准值',
                        prop: 'outlet_standard_065',
                        show: true,
                        width: '75',
                    },
                    {
                        label: '排放量(千克)',
                        prop: 'cou_value_065',
                        show: true,
                        width: '85',
                    },
                    {
                        label: '自动监测设备维护标记',
                        prop: 'flag_065',
                        show: true,
                        width: '120',
                        children: [
                            {
                                label: '自动',
                                prop: 'zd_flag_065',
                                show: true,
                                width: '85',
                            },
                            {
                                label: '人工',
                                prop: 'rg_flag_065',
                                show: true,
                                width: '85',
                            },
                        ],
                    },
                ],
            },
            {
                label: '修正值',
                prop: 'xiuzhen_065',
                show: true,
                width: '78',
                children: [
                    {
                        label: '浓度值',
                        prop: 'avg_revised_065',
                        show: true,
                        width: '78',
                    },
                    {
                        label: '排放量(千克)',
                        prop: 'cou_revised_065',
                        show: true,
                        width: '85',
                    },
                ],
            },
        ],
    },
    {
        label: '总磷(毫克/升)',
        prop: '101',
        show: true,
        width: '78',
        children: [
            {
                label: '上报值',
                prop: 'yuanshi_101',
                show: true,
                width: '78',
                children: [
                    {
                        label: '浓度',
                        prop: 'avg_value_101',
                        show: true,
                        width: '78',
                    },
                    {
                        label: '最小值',
                        prop: 'min_value_101',
                        show: false,
                        width: '78',
                    },
                    {
                        label: '最大值',
                        prop: 'max_value_101',
                        show: false,
                        width: '78',
                    },
                    {
                        label: '标准值',
                        prop: 'outlet_standard_101',
                        show: true,
                        width: '75',
                    },
                    {
                        label: '排放量(千克)',
                        prop: 'cou_value_101',
                        show: true,
                        width: '85',
                    },
                    {
                        label: '自动监测设备维护标记',
                        prop: 'flag_101',
                        show: true,
                        width: '120',
                        children: [
                            {
                                label: '自动',
                                prop: 'zd_flag_101',
                                show: true,
                                width: '85',
                            },
                            {
                                label: '人工',
                                prop: 'rg_flag_101',
                                show: true,
                                width: '85',
                            },
                        ],
                    },
                ],
            },
            {
                label: '修正值',
                prop: 'xiuzhen_101',
                show: true,
                width: '78',
                children: [
                    {
                        label: '浓度值',
                        prop: 'avg_revised_101',
                        show: true,
                        width: '78',
                    },
                    {
                        label: '排放量(千克)',
                        prop: 'cou_revised_101',
                        show: true,
                        width: '85',
                    },
                ],
            },
        ],
    },
];

const propsObj = {
    props: [
        'workcordSc',
        'zd_flag',
        'rg_flag',
        'avg_value_B',
        'cou_value_B',
        'avg_revised',
        'cou_revised_',
        'min',
        'max',
        'avg_hm_revised_S',
        'ndbjh_',
        'ndhmh_',
        'hand',
        'avg_revised_S',
        'outlet_standard_',
    ],
    dic: {
        workcordSc: {
            prop: 'workcordSc',
            checked: false,
            type: '1',
        },
        zd_flag: {
            prop: 'zd_flag',
            checked: false,
            type: '1',
        },
        rg_flag: {
            prop: 'rg_flag',
            checked: false,
            type: '1',
        },
        avg_value_B: {
            prop: 'avg_value_B',
            checked: false,
            type: '1',
        },
        cou_value_B: {
            prop: 'cou_value_B',
            checked: false,
            type: '1',
        },
        avg_revised: {
            prop: 'avg_revised',
            checked: false,
            type: '1',
        },
        cou_revised_: {
            prop: 'cou_revised_',
            checked: false,
            type: '1',
        },
        min: {
            prop: 'min',
            checked: false,
            type: '1',
        },
        max: {
            prop: 'max',
            checked: false,
            type: '1',
        },
        avg_hm_revised_S: {
            prop: 'avg_hm_revised_S',
            checked: false,
            type: '1',
        },
        ndbjh_: {
            prop: 'ndbjh_',
            checked: true,
            type: '1',
        },
        ndhmh_: {
            prop: 'ndhmh_',
            checked: true,
            type: '1',
        },
        hand: {
            prop: 'hand',
            checked: false,
            type: '1',
        },
        avg_revised_S: {
            prop: 'avg_revised_S',
            checked: false,
            type: '1',
        },
        outlet_standard_: {
            prop: 'outlet_standard_',
            checked: false,
        },
    },
};

const setShow = (tree = []) => {
    try {
        for (const v of tree) {
            const ft = propsObj.props.filter((s) => v.prop.indexOf(s) > -1);

            // if (ft.length) {
            //     console.log(v.prop);
            // }

            if (ft.length) {
                const ftProp=ft[0];
                if (propsObj.dic[ftProp] && v.show != propsObj.dic[ftProp].checked) {
                    v.show = propsObj.dic[ftProp].checked;
                    setShow(columns);
                    break;
                }
            }

            if (v.children && v.children.length) {
                if (v.show && v.children.filter((x) => x.show).length == 0) {
                    v.show = false;
                    setShow(columns);
                    break;
                }

                setShow(v.children);
            }
        }
    } catch (e) {
        console.error(e);
    }
};

setShow(columns);

console.log(columns);
console.log(treeToArray(columns));

 

标签:show,单元测试,label,width,prop,true,78
From: https://blog.51cto.com/u_15311558/8016255

相关文章

  • laravel:单元测试之http测试(10.27.0)
    一,相关文档:https://learnku.com/docs/laravel/10.x/http-tests/14896二,php代码:1,创建test程序liuhongdi@lhdpc:/data/laravel/dignews$phpartisanmake:testNewsTest   INFO  Test[tests/Feature/NewsTest.php]createdsuccessfully.2,代码:12345......
  • python技术栈之单元测试中mock的使用
    什么是mock?mock测试就是在测试过程中,对于某些不容易构造或者不容易获取的对象,用一个虚拟的对象来创建以便测试的测试方法。mock的作用特别是开发过程中上下游未完成的工序导致当前无法测试,需要虚拟某些特定对象以便测试。unittest是python内置的单元测试库,在做接口测试时,如果......
  • 5、单元测试、反射、注解、动态代理
    单元测试、反射、注解、动态代理一、单元测试1.1Junit单元测试所谓单元测试,就是针对最小的功能单元,编写测试代码对其进行正确性测试。我们想想,咱们之前是怎么进行测试的呢?比如说我们写了一个学生管理系统,有添加学生、修改学生、删除学生、查询学生等这些功能。要对这些功能......
  • 单元测试
         ......
  • Unittest单元测试框架-知识点总结
    unittest单元测试框架1.导入unittest包========================================================================2.创建类的时候要继承与unittest.TestCase类2.1,setUp方法是在类中测试执行前的初始化工作2.2,tearDown方法是在类中测试执行后的清除工作2.3,测试用例函数以test开头......
  • 无涯教程-ASP.NET MVC - 单元测试
    在计算机编程中,单元测试是一种软件测试方法,通过该方法可以测试源代码的各个单元以确定它们是否适合使用。换句话说,这是一个软件开发过程,其中应用程序的最小可测试部分(称为单元)被单独且独立地检查以确保其正常运行。单元测试通常是自动化的,但也可以手动完成。单元测试的目标......
  • 一种有效的嵌入式软件单元测试工具
     一、引言在当今的软件开发领域,单元测试已经成为确保代码质量,提升软件可靠性和安全性的重要环节。对于嵌入式软件来说,尤其在汽车控制等安全性至关重要的领域,单元测试更成为不可或缺的一部分。然而,传统的单元测试方法往往效率低下且容易出错。为了解决这一问题,本文介绍了一种有......
  • nittest单元测试框架—加载测试用例的3种方法以及测试报告存储管理
     项目结构 测试用例importunittestclassLoginTestCase(unittest.TestCase):deftest_login_success(self):self.assertEqual({'code':200,'msg':'登录成功'},self.login('kobe','666'))deftest_......
  • 使用GoogleTest框架进行cpp代码的基本单元测试
    title:aliases:tags:-cpp/单元测试-cmake-工程技术category:-方法stars:url:creation-time:2023-10-1119:02modification-time:这里主要介绍从0开始实现基本的单元测试功能。构建首先从googletest代码仓下载源码。网上很多指导包括官方的指......
  • NetCore学习笔记:单元测试和集成测试
    前言#我在使用AspNetCore的这段时间内,看了很多开源项目和博客,发现各种.Net体系的新技术很多人都有关注和使用,但却很少有人关注测试。测试是软件生命周期中的一个非常重要的阶段,对于保证软件的可靠性具有极其重要的意义。在应用程序的开发过程中,为了确保它的功能与预期一致,......