1
- import {
2
- defineComponent ,
3
- ref ,
4
- nextTick ,
5
- h ,
6
- ComponentOptionsWithoutProps ,
7
- ConcreteComponent ,
8
- onMounted ,
9
- } from 'vue'
1
+ import { defineComponent , ref , nextTick , h , ConcreteComponent , onMounted } from 'vue'
10
2
import { createRenderTemplate , render } from '../../test-utils/vue-testing-library'
11
3
12
4
import {
@@ -109,6 +101,7 @@ describe('Safe guards', () => {
109
101
110
102
describe ( 'refs' , ( ) => {
111
103
it ( 'should be possible to access the ref on the DialogBackdrop' , async ( ) => {
104
+ expect . assertions ( 2 )
112
105
renderTemplate ( {
113
106
template : `
114
107
<Dialog :open="true">
@@ -121,15 +114,18 @@ describe('refs', () => {
121
114
setup ( ) {
122
115
let backdrop = ref < { el : Element ; $el : Element } | null > ( null )
123
116
onMounted ( ( ) => {
124
- expect ( backdrop . value ?. el ) . toBeInstanceOf ( HTMLDivElement )
125
- expect ( backdrop . value ?. $el ) . toBeInstanceOf ( HTMLDivElement )
117
+ nextTick ( ( ) => {
118
+ expect ( backdrop . value ?. el ) . toBeInstanceOf ( HTMLDivElement )
119
+ expect ( backdrop . value ?. $el ) . toBeInstanceOf ( HTMLDivElement )
120
+ } )
126
121
} )
127
122
return { backdrop }
128
123
} ,
129
124
} )
130
125
} )
131
126
132
127
it ( 'should be possible to access the ref on the DialogPanel' , async ( ) => {
128
+ expect . assertions ( 2 )
133
129
renderTemplate ( {
134
130
template : `
135
131
<Dialog :open="true">
@@ -141,8 +137,10 @@ describe('refs', () => {
141
137
setup ( ) {
142
138
let panel = ref < { el : Element ; $el : Element } | null > ( null )
143
139
onMounted ( ( ) => {
144
- expect ( panel . value ?. el ) . toBeInstanceOf ( HTMLDivElement )
145
- expect ( panel . value ?. $el ) . toBeInstanceOf ( HTMLDivElement )
140
+ nextTick ( ( ) => {
141
+ expect ( panel . value ?. el ) . toBeInstanceOf ( HTMLDivElement )
142
+ expect ( panel . value ?. $el ) . toBeInstanceOf ( HTMLDivElement )
143
+ } )
146
144
} )
147
145
return { panel }
148
146
} ,
@@ -1153,6 +1151,8 @@ describe('Mouse interactions', () => {
1153
1151
} ,
1154
1152
} )
1155
1153
1154
+ await new Promise < void > ( nextTick )
1155
+
1156
1156
// Verify it is open
1157
1157
assertDialog ( { state : DialogState . Visible } )
1158
1158
@@ -1196,6 +1196,8 @@ describe('Mouse interactions', () => {
1196
1196
} ,
1197
1197
} )
1198
1198
1199
+ await new Promise < void > ( nextTick )
1200
+
1199
1201
// Verify it is open
1200
1202
assertDialog ( { state : DialogState . Visible } )
1201
1203
@@ -1233,6 +1235,8 @@ describe('Mouse interactions', () => {
1233
1235
} ,
1234
1236
} )
1235
1237
1238
+ await new Promise < void > ( nextTick )
1239
+
1236
1240
// Verify it is open
1237
1241
assertDialog ( { state : DialogState . Visible } )
1238
1242
@@ -1277,6 +1281,8 @@ describe('Mouse interactions', () => {
1277
1281
} ,
1278
1282
} )
1279
1283
1284
+ await new Promise < void > ( nextTick )
1285
+
1280
1286
// Verify it is open
1281
1287
assertDialog ( { state : DialogState . Visible } )
1282
1288
@@ -1327,6 +1333,8 @@ describe('Mouse interactions', () => {
1327
1333
} ,
1328
1334
} )
1329
1335
1336
+ await new Promise < void > ( nextTick )
1337
+
1330
1338
// Verify it is open
1331
1339
assertDialog ( { state : DialogState . Visible } )
1332
1340
0 commit comments