basicTest.uvue 1.7 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
</template>
22 23
<script lang="ts">
import { runTests, Result } from '../../uni_modules/uts-tests'
DCloud-WZF's avatar
DCloud-WZF 已提交
24 25 26 27 28 29 30
export default {
  data() {
    return {
      title: 'UTS基础语法',
      resultArray: [] as Result[],
      result: {} as UTSJSONObject,
      names: [] as string[],
Y
yurj26 已提交
31
    }
DCloud-WZF's avatar
DCloud-WZF 已提交
32 33 34 35 36 37
  },
  onReady() {
    this.test()
  },
  methods: {
    test() {
lizhongyi_'s avatar
lizhongyi_ 已提交
38 39 40 41 42 43 44 45 46 47 48
      this.result = runTests()
      // const resultMap = this.result.toMap()
      // resultMap.forEach((res, name) => {
      //   this.names.push(name)
      //   this.resultArray.push(res as Result)
      // })
      const resultMap = this.result
      for (const key in resultMap) {
        this.names.push(key)
        this.resultArray.push(resultMap[key] as Result)
      }
DCloud-WZF's avatar
DCloud-WZF 已提交
49 50 51
    },
  },
}
Y
yurj26 已提交
52
</script>
DCloud-WZF's avatar
DCloud-WZF 已提交
53 54 55 56 57
<style>
@import '@/common/uni-uvue.css';
.content {
  padding: 32rpx;
}
Y
yurj26 已提交
58

DCloud-WZF's avatar
DCloud-WZF 已提交
59 60 61
.passed {
  color: green;
}
Y
yurj26 已提交
62

DCloud-WZF's avatar
DCloud-WZF 已提交
63 64 65
.failed {
  color: red;
}
Y
yurj26 已提交
66

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