basicTest.uvue 1.5 KB
Newer Older
Y
yurj26 已提交
1
<template>
DCloud-WZF's avatar
DCloud-WZF 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14
  <!-- #ifdef APP -->
  <scroll-view style="flex: 1">
    <!-- #endif -->
    <view class="content">
      <page-head :title="title"></page-head>
      <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>
Y
yurj26 已提交
15
        </view>
DCloud-WZF's avatar
DCloud-WZF 已提交
16
      </view>
Y
yurj26 已提交
17
    </view>
DCloud-WZF's avatar
DCloud-WZF 已提交
18 19 20
    <!-- #ifdef APP -->
  </scroll-view>
  <!-- #endif -->
Y
yurj26 已提交
21 22
</template>
<script lang="ts">
DCloud-WZF's avatar
DCloud-WZF 已提交
23
import { runTests, Result } from '../../uni_modules/uts-tests'
Y
yurj26 已提交
24

DCloud-WZF's avatar
DCloud-WZF 已提交
25 26 27 28 29 30 31
export default {
  data() {
    return {
      title: 'UTS基础语法',
      resultArray: [] as Result[],
      result: {} as UTSJSONObject,
      names: [] as string[],
Y
yurj26 已提交
32
    }
DCloud-WZF's avatar
DCloud-WZF 已提交
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
  },
  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)
      })
    },
  },
}
Y
yurj26 已提交
48
</script>
DCloud-WZF's avatar
DCloud-WZF 已提交
49 50 51 52 53 54
<style>
@import '@/common/uni-uvue.css';
.content {
  min-height: 100%;
  padding: 32rpx;
}
Y
yurj26 已提交
55

DCloud-WZF's avatar
DCloud-WZF 已提交
56 57 58
.passed {
  color: green;
}
Y
yurj26 已提交
59

DCloud-WZF's avatar
DCloud-WZF 已提交
60 61 62
.failed {
  color: red;
}
Y
yurj26 已提交
63

DCloud-WZF's avatar
DCloud-WZF 已提交
64 65 66 67
.result {
  margin-bottom: 20rpx;
}
</style>