11import { describe , expect , it } from 'vitest' ;
2- import { render } from '@testing-library/ react' ;
2+ import { render } from 'vitest-browser- react' ;
33
44import Clock from './Clock.js' ;
55
66describe ( 'Clock' , ( ) => {
77 describe ( '<time> element' , ( ) => {
8- it ( 'is rendered properly' , ( ) => {
9- const { container } = render ( < Clock /> ) ;
8+ it ( 'is rendered properly' , async ( ) => {
9+ const { container } = await render ( < Clock /> ) ;
1010
1111 const time = container . querySelector ( 'time' ) ;
1212
1313 expect ( time ) . toBeInTheDocument ( ) ;
1414 } ) ;
1515
16- it ( 'has 150px size by default' , ( ) => {
17- const { container } = render ( < Clock /> ) ;
16+ it ( 'has 150px size by default' , async ( ) => {
17+ const { container } = await render ( < Clock /> ) ;
1818
1919 const time = container . querySelector ( 'time' ) ;
2020
2121 expect ( time ) . toHaveStyle ( 'width: 150px' ) ;
2222 expect ( time ) . toHaveStyle ( 'height: 150px' ) ;
2323 } ) ;
2424
25- it ( 'has proper size when given size' , ( ) => {
25+ it ( 'has proper size when given size' , async ( ) => {
2626 const size = 167 ;
2727
28- const { container } = render ( < Clock size = { size } /> ) ;
28+ const { container } = await render ( < Clock size = { size } /> ) ;
2929
3030 const time = container . querySelector ( 'time' ) ;
3131
3232 expect ( time ) . toHaveAttribute ( 'style' , `width: ${ size } px; height: ${ size } px;` ) ;
3333 } ) ;
3434
35- it ( 'has proper datetime attribute when given Date value' , ( ) => {
35+ it ( 'has proper datetime attribute when given Date value' , async ( ) => {
3636 const date = new Date ( ) ;
3737
38- const { container } = render ( < Clock value = { date } /> ) ;
38+ const { container } = await render ( < Clock value = { date } /> ) ;
3939
4040 const time = container . querySelector ( 'time' ) ;
4141
@@ -50,10 +50,10 @@ describe('Clock', () => {
5050 ) ;
5151 } ) ;
5252
53- it ( 'has proper datetime attribute when given string value' , ( ) => {
53+ it ( 'has proper datetime attribute when given string value' , async ( ) => {
5454 const date = '22:17:00' ;
5555
56- const { container } = render ( < Clock value = { date } /> ) ;
56+ const { container } = await render ( < Clock value = { date } /> ) ;
5757
5858 const time = container . querySelector ( 'time' ) ;
5959
@@ -62,16 +62,16 @@ describe('Clock', () => {
6262 } ) ;
6363
6464 describe ( 'clock face' , ( ) => {
65- it ( 'is rendered properly' , ( ) => {
66- const { container } = render ( < Clock /> ) ;
65+ it ( 'is rendered properly' , async ( ) => {
66+ const { container } = await render ( < Clock /> ) ;
6767
6868 const face = container . querySelector ( '.react-clock__face' ) ;
6969
7070 expect ( face ) . toBeInTheDocument ( ) ;
7171 } ) ;
7272
73- it ( 'has hour and minute marks by default' , ( ) => {
74- const { container } = render ( < Clock /> ) ;
73+ it ( 'has hour and minute marks by default' , async ( ) => {
74+ const { container } = await render ( < Clock /> ) ;
7575
7676 const hourMarks = container . querySelectorAll ( '.react-clock__hour-mark' ) ;
7777 const minuteMarks = container . querySelectorAll ( '.react-clock__minute-mark' ) ;
@@ -80,16 +80,16 @@ describe('Clock', () => {
8080 expect ( minuteMarks ) . toHaveLength ( 60 - 12 ) ;
8181 } ) ;
8282
83- it ( 'does not have hour numbers rendered by default' , ( ) => {
84- const { container } = render ( < Clock /> ) ;
83+ it ( 'does not have hour numbers rendered by default' , async ( ) => {
84+ const { container } = await render ( < Clock /> ) ;
8585
8686 const hourMarks = container . querySelectorAll ( '.react-clock__hour-mark' ) ;
8787
8888 expect ( hourMarks [ 0 ] ) . not . toHaveTextContent ( '1' ) ;
8989 } ) ;
9090
91- it ( 'has hour numbers given renderNumbers flag' , ( ) => {
92- const { container } = render ( < Clock renderNumbers /> ) ;
91+ it ( 'has hour numbers given renderNumbers flag' , async ( ) => {
92+ const { container } = await render ( < Clock renderNumbers /> ) ;
9393
9494 const numberMarks = container . querySelectorAll ( '.react-clock__number-mark' ) ;
9595
@@ -98,17 +98,17 @@ describe('Clock', () => {
9898 } ) ;
9999 } ) ;
100100
101- it ( 'uses formatHour properly if given' , ( ) => {
101+ it ( 'uses formatHour properly if given' , async ( ) => {
102102 const formatHour = ( ) => 'H' ;
103- const { container } = render ( < Clock formatHour = { formatHour } renderNumbers /> ) ;
103+ const { container } = await render ( < Clock formatHour = { formatHour } renderNumbers /> ) ;
104104
105105 const numberMarks = container . querySelectorAll ( '.react-clock__number-mark' ) ;
106106
107107 expect ( numberMarks [ 0 ] ) . toHaveTextContent ( 'H' ) ;
108108 } ) ;
109109
110- it ( 'has only minute marks when renderHourMarks is false' , ( ) => {
111- const { container } = render ( < Clock renderHourMarks = { false } /> ) ;
110+ it ( 'has only minute marks when renderHourMarks is false' , async ( ) => {
111+ const { container } = await render ( < Clock renderHourMarks = { false } /> ) ;
112112
113113 const hourMarks = container . querySelectorAll ( '.react-clock__hour-mark' ) ;
114114 const minuteMarks = container . querySelectorAll ( '.react-clock__minute-mark' ) ;
@@ -117,8 +117,8 @@ describe('Clock', () => {
117117 expect ( minuteMarks ) . toHaveLength ( 60 ) ;
118118 } ) ;
119119
120- it ( 'has only hour marks when renderMinuteMarks is false' , ( ) => {
121- const { container } = render ( < Clock renderMinuteMarks = { false } /> ) ;
120+ it ( 'has only hour marks when renderMinuteMarks is false' , async ( ) => {
121+ const { container } = await render ( < Clock renderMinuteMarks = { false } /> ) ;
122122
123123 const hourMarks = container . querySelectorAll ( '.react-clock__hour-mark' ) ;
124124 const minuteMarks = container . querySelectorAll ( '.react-clock__minute-mark' ) ;
@@ -127,8 +127,10 @@ describe('Clock', () => {
127127 expect ( minuteMarks ) . toHaveLength ( 0 ) ;
128128 } ) ;
129129
130- it ( 'has no marks when renderHourMarks and renderMinuteMarks are false' , ( ) => {
131- const { container } = render ( < Clock renderHourMarks = { false } renderMinuteMarks = { false } /> ) ;
130+ it ( 'has no marks when renderHourMarks and renderMinuteMarks are false' , async ( ) => {
131+ const { container } = await render (
132+ < Clock renderHourMarks = { false } renderMinuteMarks = { false } /> ,
133+ ) ;
132134
133135 const hourMarks = container . querySelectorAll ( '.react-clock__hour-mark' ) ;
134136 const minuteMarks = container . querySelectorAll ( '.react-clock__minute-mark' ) ;
@@ -183,21 +185,21 @@ describe('Clock', () => {
183185 }
184186
185187 describe ( 'hour hand' , ( ) => {
186- it ( 'is rendered properly' , ( ) => {
187- const { container } = render ( < Clock /> ) ;
188+ it ( 'is rendered properly' , async ( ) => {
189+ const { container } = await render ( < Clock /> ) ;
188190
189191 const hand = container . querySelector ( '.react-clock__hour-hand' ) ;
190192
191193 expect ( hand ) . toBeInTheDocument ( ) ;
192194 } ) ;
193195
194- it ( 'is properly angled by default' , ( ) => {
196+ it ( 'is properly angled by default' , async ( ) => {
195197 const hour = 9 ;
196198 const minute = 20 ;
197199 const second = 47 ;
198200 const date = new Date ( 2017 , 0 , 1 , hour , minute , second ) ;
199201
200- const { container } = render ( < Clock value = { date } /> ) ;
202+ const { container } = await render ( < Clock value = { date } /> ) ;
201203
202204 const hand = container . querySelector ( '.react-clock__hour-hand' ) as HTMLDivElement ;
203205
@@ -206,14 +208,14 @@ describe('Clock', () => {
206208 ) ;
207209 } ) ;
208210
209- it ( 'is properly angled when given useMillisecondPrecision' , ( ) => {
211+ it ( 'is properly angled when given useMillisecondPrecision' , async ( ) => {
210212 const hour = 9 ;
211213 const minute = 20 ;
212214 const second = 47 ;
213215 const millisecond = 321 ;
214216 const date = new Date ( 2017 , 0 , 1 , hour , minute , second , millisecond ) ;
215217
216- const { container } = render ( < Clock useMillisecondPrecision value = { date } /> ) ;
218+ const { container } = await render ( < Clock useMillisecondPrecision value = { date } /> ) ;
217219
218220 const hand = container . querySelector ( '.react-clock__hour-hand' ) as HTMLDivElement ;
219221
@@ -227,43 +229,43 @@ describe('Clock', () => {
227229 } ) ;
228230
229231 describe ( 'minute hand' , ( ) => {
230- it ( 'is rendered properly' , ( ) => {
231- const { container } = render ( < Clock /> ) ;
232+ it ( 'is rendered properly' , async ( ) => {
233+ const { container } = await render ( < Clock /> ) ;
232234
233235 const hand = container . querySelector ( '.react-clock__minute-hand' ) ;
234236
235237 expect ( hand ) . toBeInTheDocument ( ) ;
236238 } ) ;
237239
238- it ( 'is not rendered when renderMinuteHand is false' , ( ) => {
239- const { container } = render ( < Clock renderMinuteHand = { false } /> ) ;
240+ it ( 'is not rendered when renderMinuteHand is false' , async ( ) => {
241+ const { container } = await render ( < Clock renderMinuteHand = { false } /> ) ;
240242
241243 const hand = container . querySelector ( '.react-clock__minute-hand' ) ;
242244
243245 expect ( hand ) . not . toBeInTheDocument ( ) ;
244246 } ) ;
245247
246- it ( 'is properly angled by default' , ( ) => {
248+ it ( 'is properly angled by default' , async ( ) => {
247249 const hour = 9 ;
248250 const minute = 20 ;
249251 const second = 47 ;
250252 const date = new Date ( 2017 , 0 , 1 , hour , minute , second ) ;
251253
252- const { container } = render ( < Clock value = { date } /> ) ;
254+ const { container } = await render ( < Clock value = { date } /> ) ;
253255
254256 const hand = container . querySelector ( '.react-clock__minute-hand' ) as HTMLDivElement ;
255257
256258 expect ( getAngle ( hand ) ) . toBeCloseTo ( minute * minuteAngle + second * minuteSecondAngle ) ;
257259 } ) ;
258260
259- it ( 'is properly angled when given useMillisecondPrecision' , ( ) => {
261+ it ( 'is properly angled when given useMillisecondPrecision' , async ( ) => {
260262 const hour = 9 ;
261263 const minute = 20 ;
262264 const second = 47 ;
263265 const millisecond = 321 ;
264266 const date = new Date ( 2017 , 0 , 1 , hour , minute , second , millisecond ) ;
265267
266- const { container } = render ( < Clock useMillisecondPrecision value = { date } /> ) ;
268+ const { container } = await render ( < Clock useMillisecondPrecision value = { date } /> ) ;
267269
268270 const hand = container . querySelector ( '.react-clock__minute-hand' ) as HTMLDivElement ;
269271
@@ -274,43 +276,43 @@ describe('Clock', () => {
274276 } ) ;
275277
276278 describe ( 'second hand' , ( ) => {
277- it ( 'is rendered properly' , ( ) => {
278- const { container } = render ( < Clock /> ) ;
279+ it ( 'is rendered properly' , async ( ) => {
280+ const { container } = await render ( < Clock /> ) ;
279281
280282 const hand = container . querySelector ( '.react-clock__second-hand' ) ;
281283
282284 expect ( hand ) . toBeInTheDocument ( ) ;
283285 } ) ;
284286
285- it ( 'is not rendered when renderSecondHand is false' , ( ) => {
286- const { container } = render ( < Clock renderSecondHand = { false } /> ) ;
287+ it ( 'is not rendered when renderSecondHand is false' , async ( ) => {
288+ const { container } = await render ( < Clock renderSecondHand = { false } /> ) ;
287289
288290 const hand = container . querySelector ( '.react-clock__second-hand' ) ;
289291
290292 expect ( hand ) . not . toBeInTheDocument ( ) ;
291293 } ) ;
292294
293- it ( 'is properly angled by default' , ( ) => {
295+ it ( 'is properly angled by default' , async ( ) => {
294296 const hour = 9 ;
295297 const minute = 20 ;
296298 const second = 47 ;
297299 const date = new Date ( 2017 , 0 , 1 , hour , minute , second ) ;
298300
299- const { container } = render ( < Clock value = { date } /> ) ;
301+ const { container } = await render ( < Clock value = { date } /> ) ;
300302
301303 const hand = container . querySelector ( '.react-clock__second-hand' ) as HTMLDivElement ;
302304
303305 expect ( getAngle ( hand ) ) . toBeCloseTo ( second * secondAngle ) ;
304306 } ) ;
305307
306- it ( 'is properly angled when given useMillisecondPrecision' , ( ) => {
308+ it ( 'is properly angled when given useMillisecondPrecision' , async ( ) => {
307309 const hour = 9 ;
308310 const minute = 20 ;
309311 const second = 47 ;
310312 const millisecond = 321 ;
311313 const date = new Date ( 2017 , 0 , 1 , hour , minute , second , millisecond ) ;
312314
313- const { container } = render ( < Clock useMillisecondPrecision value = { date } /> ) ;
315+ const { container } = await render ( < Clock useMillisecondPrecision value = { date } /> ) ;
314316
315317 const hand = container . querySelector ( '.react-clock__second-hand' ) as HTMLDivElement ;
316318
0 commit comments