File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
packages/hooks/src/useFetchs Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change
1
+ import { mount } from '@vue/test-utils'
2
+ import { sleep } from '@/utils/sleep'
3
+
4
+ import Demo from '../demo/demo.vue'
5
+
6
+ describe ( 'useFetchs' , ( ) => {
7
+ it ( 'should work' , async ( ) => {
8
+ const wrapper = mount ( Demo )
9
+
10
+ const showText0 = wrapper . findAll ( '.item' ) . at ( 0 )
11
+ const showText1 = wrapper . findAll ( '.item' ) . at ( 1 )
12
+ const showText2 = wrapper . findAll ( '.item' ) . at ( 2 )
13
+ const showText3 = wrapper . findAll ( '.item' ) . at ( 3 )
14
+
15
+ expect ( showText0 ?. text ( ) ) . toBe ( 'loading' )
16
+ expect ( showText1 ?. text ( ) ) . toBe ( 'loading' )
17
+ expect ( showText2 ?. text ( ) ) . toBe ( 'loading' )
18
+ expect ( showText3 ?. text ( ) ) . toBe ( 'loading' )
19
+
20
+ await sleep ( 2000 )
21
+ expect ( showText0 ?. text ( ) ) . toBe ( 'vue-hooks-plus 牛' )
22
+ expect ( showText1 ?. text ( ) ) . toBe ( 'vue-hooks-plus 小牛' )
23
+ expect ( showText2 ?. text ( ) ) . toBe ( 'vue-hooks-plus 中牛' )
24
+ expect ( showText3 ?. text ( ) ) . toBe ( 'loading' )
25
+
26
+ await sleep ( 2000 )
27
+ expect ( showText3 ?. text ( ) ) . toBe ( 'vue-hooks-plus 大牛' )
28
+ } )
29
+ } )
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div >
3
- <div v-for =" item in datas" :key =" item.key" >
3
+ <div v-for =" item in datas" :key =" item.key" class = " item " >
4
4
{{ item.loading ? 'loading' : '' }}
5
5
{{ item.data }}
6
6
</div >
You can’t perform that action at this time.
0 commit comments