File tree Expand file tree Collapse file tree 2 files changed +51
-5
lines changed Expand file tree Collapse file tree 2 files changed +51
-5
lines changed Original file line number Diff line number Diff line change
1
+ import { screen , render , fireEvent } from '@testing-library/react' ;
2
+ import '@testing-library/jest-dom/extend-expect' ;
3
+ import LandingPage from '../src/pages/components/LandingPage' ;
4
+ import Blogs from '../src/pages/components/Blogs' ;
5
+ import People from '../src/pages/components/TeamSection' ;
6
+ import FeaturesSection from '../src/pages/components/FeaturesSection' ;
7
+ import { trpc } from '../src/utils/trpc' ;
8
+ // Work in progress. Trying to mock the trpc object
9
+
10
+
11
+ jest . mock ( "../src/utils/trpc" , ( ) => {
12
+ const mockCreateUser = jest . fn ( ) ;
13
+ const mockFindAll = jest . fn ( ) ;
14
+
15
+ const mockUserRouter = {
16
+ createUser : mockCreateUser ,
17
+ findAll : mockFindAll
18
+ } ;
19
+
20
+ const mockAppRouter = {
21
+ user : mockUserRouter
22
+ } ;
23
+ return {
24
+ appRouter : mockAppRouter
25
+ } ;
26
+ } ) ;
27
+
28
+ describe ( 'Navbar Component Test ' , ( ) => {
29
+ beforeEach ( ( ) => {
30
+ render ( < LandingPage /> )
31
+ } ) ;
32
+
33
+ it ( 'check that the button is rendered on the page' , ( ) => {
34
+ const button = screen . getByRole ( 'button' ) ;
35
+ console . debug ( button )
36
+ expect ( button ) . toHaveLength ( 1 ) ;
37
+ expect ( screen . getByText ( "A time travel debugger for modern react apps" ) ) . toBeInTheDocument ( ) ;
38
+ } ) ;
39
+ } ) ;
Original file line number Diff line number Diff line change 1
1
import { screen , render } from '@testing-library/react' ;
2
2
import '@testing-library/jest-dom/extend-expect' ;
3
- import { Profile } from '../src/pages/components/TeamSection' ;
3
+ import People , { Profile } from '../src/pages/components/TeamSection' ;
4
4
5
5
// http://localhost/_next/image?url=https%3A%2F%2Fgithub.com%2Fwiltonlee948.png&w=256&q=75
6
6
7
- test ( 'sets src to /profileFallback.png if src causes an error' , async ( ) => {
8
- render ( < Profile key = '' profile = 'qcvber' name = '' /> ) ;
9
- const src = screen . getByTestId ( 'image' ) . getAttribute ( 'src' ) ;
10
- console . debug ( src )
7
+ it ( 'test to see if all the contributor images show up' , async ( ) => {
8
+ render ( < People /> ) ;
9
+ const image = screen . getAllByTestId ( 'image' ) ;
10
+ expect ( image . length ) . toBe ( 72 ) ;
11
+ } ) ;
12
+
13
+
14
+ test ( 'the value from the profile attribute should be in the src' , async ( ) => {
15
+ render ( < Profile key = '' profile = 'react' name = '' /> ) ;
16
+ const src = await screen . getByTestId ( 'image' ) . getAttribute ( 'src' ) ;
17
+ expect ( src ) . toContain ( 'react' ) ;
11
18
} ) ;
You can’t perform that action at this time.
0 commit comments