File tree 4 files changed +60
-11
lines changed
4 files changed +60
-11
lines changed Original file line number Diff line number Diff line change 5
5
"dependencies" : {
6
6
"@testing-library/jest-dom" : " ^5.16.5" ,
7
7
"@testing-library/react" : " ^13.4.0" ,
8
- "@testing-library/user-event" : " ^12.1.10 " ,
8
+ "@testing-library/user-event" : " ^14.4.3 " ,
9
9
"framer-motion" : " 4.1.17" ,
10
10
"postcss-cli" : " ^10.1.0" ,
11
11
"react" : " ^18.1.0" ,
45
45
},
46
46
"devDependencies" : {
47
47
"@tailwindcss/forms" : " ^0.5.2" ,
48
+ "@testing-library/dom" : " ^8.20.0" ,
48
49
"autoprefixer" : " ^10.4.7" ,
49
50
"postcss" : " ^8.4.21" ,
50
51
"tailwindcss" : " ^3.0.24"
Original file line number Diff line number Diff line change @@ -13,8 +13,33 @@ function setupUserEvent(jsx) {
13
13
} ;
14
14
}
15
15
16
- test ( 'it shows the name in banner' , ( ) => {
16
+ test ( 'it shows the title in the banner' , ( ) => {
17
17
setup ( ) ;
18
- const titleElement = screen . getByText ( / H i , I a m S t o m a n / i) ;
19
- expect ( titleElement ) . toBeInTheDocument ( ) ;
18
+ // We expect that the title 'Hi, Iam Stoman' is in the banner component
19
+ expect ( screen . getByText ( / H i , I a m S t o m a n / i) ) . toBeInTheDocument ( ) ;
20
+ } ) ;
21
+
22
+ test ( 'can download cv when clicked on download cv button' , async ( ) => {
23
+ const { user } = setupUserEvent ( < AppBanner /> ) ;
24
+
25
+ const downloadCV = screen . getByText ( / D o w n l o a d C V / i) ;
26
+
27
+ expect ( downloadCV ) . toBeInTheDocument ( ) ;
28
+
29
+ const downloadCVButton = downloadCV . parentElement . parentElement ;
30
+
31
+ expect ( downloadCVButton ) . toBeInTheDocument ( ) ;
32
+
33
+ await user . click ( downloadCVButton ) ;
34
+
35
+ // const downloadLink = {
36
+ // click: await user.click(downloadCVButton),
37
+ // };
38
+ // jest.spyOn(document, 'createElement').mockImplementation(
39
+ // () => downloadLink
40
+ // );
41
+
42
+ // expect(downloadLink.download).toEqual('Stoman-Resume.pdf');
43
+ // expect(downloadLink.href).toEqual('/files/Stoman-Resume.pdf');
44
+ // expect(downloadLink.click).toHaveBeenCalledTimes(1);
20
45
} ) ;
Original file line number Diff line number Diff line change
1
+ import { render , screen } from '@testing-library/react' ;
2
+ import userEvent from '@testing-library/user-event' ;
3
+ import HireMeModal from '../components/HireMeModal' ;
4
+
5
+ // Get user event
6
+ function setupUserEvent ( jsx ) {
7
+ return {
8
+ user : userEvent . setup ( ) ,
9
+ ...render ( jsx ) ,
10
+ } ;
11
+ }
12
+
13
+ test ( 'modal shows the children and a close button' , async ( ) => {
14
+ const { user } = setupUserEvent ( < HireMeModal /> ) ;
15
+
16
+ expect (
17
+ screen . getByText ( / W h a t p r o j e c t a r e y o u l o o k i n g f o r ? / i)
18
+ ) . toBeInTheDocument ( ) ;
19
+
20
+ const closeModal = screen . getByText ( / C l o s e / i) ;
21
+ expect ( closeModal ) . toBeInTheDocument ( ) ;
22
+
23
+ const closeModalButton = closeModal . parentElement ;
24
+ expect ( closeModalButton ) . toBeInTheDocument ( ) ;
25
+ } ) ;
Original file line number Diff line number Diff line change 1714
1714
dependencies :
1715
1715
mini-svg-data-uri "^1.2.3"
1716
1716
1717
- " @testing-library/dom@^8.5.0 " :
1717
+ " @testing-library/dom@^8.20.0 " , "@testing-library/dom@^8. 5.0":
1718
1718
version "8.20.0"
1719
1719
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.20.0.tgz#914aa862cef0f5e89b98cc48e3445c4c921010f6"
1720
1720
integrity sha512-d9ULIT+a4EXLX3UU8FBjauG9NnsZHkHztXoIcTsOKoOw030fyjheN9svkTULjJxtYag9DZz5Jz5qkWZDPxTFwA==
1752
1752
" @testing-library/dom" " ^8.5.0"
1753
1753
" @types/react-dom" " ^18.0.0"
1754
1754
1755
- " @testing-library/user-event@^12.1.10 " :
1756
- version "12.8.3"
1757
- resolved "https://registry.npmjs.org/@testing-library/user-event/-/user-event-12.8.3.tgz"
1758
- integrity sha512-IR0iWbFkgd56Bu5ZI/ej8yQwrkCv8Qydx6RzwbKz9faXazR/+5tvYKsZQgyXJiwgpcva127YO6JcWy7YlCfofQ==
1759
- dependencies :
1760
- " @babel/runtime" " ^7.12.5"
1755
+ " @testing-library/user-event@^14.4.3 " :
1756
+ version "14.4.3"
1757
+ resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-14.4.3.tgz#af975e367743fa91989cd666666aec31a8f50591"
1758
+ integrity sha512-kCUc5MEwaEMakkO5x7aoD+DLi02ehmEM2QCGWvNqAS1dV/fAvORWEjnjsEIvml59M7Y5kCkWN6fCCyPOe8OL6Q==
1761
1759
1762
1760
" @tootallnate/once@1 " :
1763
1761
version "1.1.2"
You can’t perform that action at this time.
0 commit comments