basicTest.uvue 1.7 KB
Newer Older
Y
yurj26 已提交
1
<template>
2 3
    <view class="content">
		<page-head :title="title"></page-head>
Y
yurj26 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
        <view v-for="(item,index) in resultArray" :key="index" class="result">
            <view>{{names[index]}}测试结果:</view>
            <view>
                测试api:{{item.passed.join(', ')}}
            </view>
            <view>总共:{{item.total}}</view>
            <view>通过:{{item.passed.length}}</view>
            <view>失败:{{item.failed.length}}</view>
            <view v-for="(fail,i) in item.failed" :key="i">
                <text class="failed">{{fail}}</text>
            </view>
        </view>
    </view>
</template>
<script lang="ts">
    import {
        runTests,
        Result
    } from '../../uni_modules/uts-tests'

    export default {
        data() {
26 27
            return {
				title: 'UTS基础语法',
Y
yurj26 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
                resultArray: [] as Result[],
                result: {} as UTSJSONObject,
                names: [] as string[]
            }
        },
        onReady() {
            this.test()
        },
        methods: {
            test() {
                this.result = runTests()
                const resultMap = this.result.toMap()
                resultMap.forEach((res, name) => {
                    this.names.push(name)
                    this.resultArray.push(res as Result)
                })
            }
        }
    }
</script>
48 49 50 51
<style>
	@import '@/common/uni-uvue.css';
    .content {
		min-height: 100%;
Y
yurj26 已提交
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
        padding: 32rpx;
    }

    .passed {
        color: green;
    }

    .failed {
        color: red;
    }

    .result {
        margin-bottom: 20rpx;
    }
</style>