File tree Expand file tree Collapse file tree 4 files changed +60
-11
lines changed Expand file tree Collapse file tree 4 files changed +60
-11
lines changed Original file line number Diff line number Diff line change 55 "dependencies" : {
66 "@testing-library/jest-dom" : " ^5.16.5" ,
77 "@testing-library/react" : " ^13.4.0" ,
8- "@testing-library/user-event" : " ^12.1.10 " ,
8+ "@testing-library/user-event" : " ^14.4.3 " ,
99 "framer-motion" : " 4.1.17" ,
1010 "postcss-cli" : " ^10.1.0" ,
1111 "react" : " ^18.1.0" ,
4545 },
4646 "devDependencies" : {
4747 "@tailwindcss/forms" : " ^0.5.2" ,
48+ "@testing-library/dom" : " ^8.20.0" ,
4849 "autoprefixer" : " ^10.4.7" ,
4950 "postcss" : " ^8.4.21" ,
5051 "tailwindcss" : " ^3.0.24"
Original file line number Diff line number Diff line change @@ -13,8 +13,33 @@ function setupUserEvent(jsx) {
1313 } ;
1414}
1515
16- test ( 'it shows the name in banner' , ( ) => {
16+ test ( 'it shows the title in the banner' , ( ) => {
1717 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);
2045} ) ;
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 17141714 dependencies :
17151715 mini-svg-data-uri "^1.2.3"
17161716
1717- " @testing-library/dom@^8.5.0 " :
1717+ " @testing-library/dom@^8.20.0 " , "@testing-library/dom@^8. 5.0":
17181718 version "8.20.0"
17191719 resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.20.0.tgz#914aa862cef0f5e89b98cc48e3445c4c921010f6"
17201720 integrity sha512-d9ULIT+a4EXLX3UU8FBjauG9NnsZHkHztXoIcTsOKoOw030fyjheN9svkTULjJxtYag9DZz5Jz5qkWZDPxTFwA==
17521752 " @testing-library/dom" " ^8.5.0"
17531753 " @types/react-dom" " ^18.0.0"
17541754
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==
17611759
17621760" @tootallnate/once@1 " :
17631761 version "1.1.2"
You can’t perform that action at this time.
0 commit comments