1
1
import React from 'react'
2
2
import { renderToStaticMarkup } from 'react-dom/server'
3
3
import '@testing-library/jest-dom/extend-expect'
4
- import {
5
- render ,
6
- RenderResult ,
7
- fireEvent ,
8
- cleanup ,
9
- } from '@testing-library/react'
4
+ import { render , RenderResult , fireEvent } from '@testing-library/react'
10
5
11
6
import { Drawer } from '.'
12
7
@@ -33,45 +28,45 @@ describe('Drawer', () => {
33
28
renderToStaticMarkup ( children )
34
29
)
35
30
} )
31
+ } )
36
32
37
- describe ( 'and the `isOpen` attribute and `onClose` callback are provided' , ( ) => {
38
- beforeEach ( ( ) => {
39
- cleanup ( )
40
- onCloseSpy = jest . fn ( )
33
+ describe ( 'and the `isOpen` attribute and `onClose` callback are provided' , ( ) => {
34
+ beforeEach ( ( ) => {
35
+ children = < h1 > Arbitrary JSX </ h1 >
36
+ onCloseSpy = jest . fn ( )
41
37
42
- wrapper = render (
43
- < Drawer isOpen onClose = { onCloseSpy } >
44
- { children }
45
- </ Drawer >
46
- )
47
- } )
38
+ wrapper = render (
39
+ < Drawer isOpen onClose = { onCloseSpy } >
40
+ { children }
41
+ </ Drawer >
42
+ )
43
+ } )
48
44
49
- it ( 'applies the `is-open` class' , ( ) => {
50
- expect ( wrapper . getByTestId ( 'drawer-wrapper' ) . classList ) . toContain (
51
- 'is-open'
45
+ it ( 'applies the `is-open` class' , ( ) => {
46
+ expect ( wrapper . getByTestId ( 'drawer-wrapper' ) . classList ) . toContain (
47
+ 'is-open'
48
+ )
49
+ } )
50
+
51
+ describe ( 'and a user clicks on the close button' , ( ) => {
52
+ beforeEach ( ( ) => {
53
+ fireEvent (
54
+ wrapper . getByTestId ( 'drawer-close' ) ,
55
+ new MouseEvent ( 'click' , {
56
+ bubbles : true ,
57
+ cancelable : true ,
58
+ } )
52
59
)
53
60
} )
54
61
55
- describe ( 'and a user clicks on the close button' , ( ) => {
56
- beforeEach ( ( ) => {
57
- fireEvent (
58
- wrapper . getByTestId ( 'drawer-close' ) ,
59
- new MouseEvent ( 'click' , {
60
- bubbles : true ,
61
- cancelable : true ,
62
- } )
63
- )
64
- } )
65
-
66
- it ( 'invokes the `onClose` callback' , ( ) => {
67
- expect ( onCloseSpy ) . toHaveBeenCalled ( )
68
- } )
62
+ it ( 'invokes the `onClose` callback' , ( ) => {
63
+ expect ( onCloseSpy ) . toHaveBeenCalled ( )
64
+ } )
69
65
70
- it ( 'removes the `is-open` class' , ( ) => {
71
- expect ( wrapper . getByTestId ( 'drawer-wrapper' ) . classList ) . not . toContain (
72
- 'is-open'
73
- )
74
- } )
66
+ it ( 'removes the `is-open` class' , ( ) => {
67
+ expect ( wrapper . getByTestId ( 'drawer-wrapper' ) . classList ) . not . toContain (
68
+ 'is-open'
69
+ )
75
70
} )
76
71
} )
77
72
} )
0 commit comments