basicTest.uvue 1.9 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
<script lang="ts">
23 24
import { runTests, Result } from '../../uni_modules/uts-tests'
// #ifdef APP-IOS
杜庆泉's avatar
杜庆泉 已提交
25
import { testTypeFromAppJs, Options } from '@/uni_modules/uts-ios-tests'
26
// #endif
DCloud-WZF's avatar
DCloud-WZF 已提交
27 28 29 30 31 32
export default {
  data() {
    return {
      title: 'UTS基础语法',
      resultArray: [] as Result[],
      result: {} as UTSJSONObject,
杜庆泉's avatar
杜庆泉 已提交
33
      names: [] as string[],
Y
yurj26 已提交
34
    }
DCloud-WZF's avatar
DCloud-WZF 已提交
35 36 37 38 39 40
  },
  onReady() {
    this.test()
  },
  methods: {
    test() {
lizhongyi_'s avatar
lizhongyi_ 已提交
41 42 43 44 45 46 47 48 49 50
      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)
杜庆泉's avatar
杜庆泉 已提交
51
      }
52 53 54 55
    },
    // #ifdef APP-IOS
    jest_testTypeFromAppJs() {
      return testTypeFromAppJs({
杜庆泉's avatar
杜庆泉 已提交
56
        num: 1
57 58 59
      } as Options)
    }
    // #endif
DCloud-WZF's avatar
DCloud-WZF 已提交
60 61
  },
}
Y
yurj26 已提交
62
</script>
DCloud-WZF's avatar
DCloud-WZF 已提交
63 64 65 66 67
<style>
@import '@/common/uni-uvue.css';
.content {
  padding: 32rpx;
}
Y
yurj26 已提交
68

DCloud-WZF's avatar
DCloud-WZF 已提交
69 70 71
.passed {
  color: green;
}
Y
yurj26 已提交
72

DCloud-WZF's avatar
DCloud-WZF 已提交
73 74 75
.failed {
  color: red;
}
Y
yurj26 已提交
76

DCloud-WZF's avatar
DCloud-WZF 已提交
77 78 79 80
.result {
  margin-bottom: 20rpx;
}
</style>