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
</template>
22 23 24 25
<script lang="ts">
// #ifdef APP
import { runTests, Result } from '../../uni_modules/uts-tests'
// #endif
DCloud-WZF's avatar
DCloud-WZF 已提交
26 27 28 29 30 31 32
export default {
  data() {
    return {
      title: 'UTS基础语法',
      resultArray: [] as Result[],
      result: {} as UTSJSONObject,
      names: [] as string[],
Y
yurj26 已提交
33
    }
DCloud-WZF's avatar
DCloud-WZF 已提交
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
  },
  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 已提交
49
</script>
DCloud-WZF's avatar
DCloud-WZF 已提交
50 51 52 53 54
<style>
@import '@/common/uni-uvue.css';
.content {
  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>