@@ -3,8 +3,77 @@ import { BrowserRouter, Route, Routes } from "react-router";
3
3
import App from "./App" ;
4
4
import React from "react" ;
5
5
import userEvent from "@testing-library/user-event" ;
6
+ import { IResponse } from "./types/speakers" ;
7
+ import axios , { AxiosHeaders , AxiosResponse } from "axios" ;
8
+
9
+ jest . mock ( "axios" ) ;
10
+ const mockedAxios = axios as jest . Mocked < typeof axios > ;
11
+ const axiosHeaders = new AxiosHeaders ( ) ;
12
+ const payload : AxiosResponse < IResponse [ ] > = {
13
+ status : 200 ,
14
+ statusText : "OK" ,
15
+ headers : { } ,
16
+ config : {
17
+ headers : axiosHeaders ,
18
+ } ,
19
+ data : [
20
+ {
21
+ id : "1" ,
22
+ fullName : "John Smith" ,
23
+ profilePicture : "https://example.com/john.jpg" ,
24
+ tagLine : "Software engineer" ,
25
+ bio : "I am a software engineer" ,
26
+ sessions : [
27
+ {
28
+ id : 4567 ,
29
+ name : "sample session" ,
30
+ } ,
31
+ ] ,
32
+ links : [
33
+ {
34
+ linkType : "Twitter" ,
35
+ url : "https://twitter.com/johnsmith" ,
36
+ title : "" ,
37
+ } ,
38
+ {
39
+ linkType : "LinkedIn" ,
40
+ url : "https://linkedin.com/in/johnsmith" ,
41
+ title : "" ,
42
+ } ,
43
+ ] ,
44
+ } ,
45
+ {
46
+ id : "2" ,
47
+ fullName : "Jane Doe" ,
48
+ profilePicture : "https://example.com/jane.jpg" ,
49
+ tagLine : "Data scientist" ,
50
+ bio : "I am a data scientist" ,
51
+ sessions : [ ] ,
52
+ links : [
53
+ {
54
+ linkType : "Twitter" ,
55
+ url : "https://twitter.com/janedoe" ,
56
+ title : "" ,
57
+ } ,
58
+ {
59
+ linkType : "LinkedIn" ,
60
+ url : "https://linkedin.com/in/janedoe" ,
61
+ title : "" ,
62
+ } ,
63
+ ] ,
64
+ } ,
65
+ ] ,
66
+ } ;
6
67
7
68
describe ( "navigation pages" , ( ) => {
69
+ beforeAll ( ( ) => {
70
+ jest . mock ( "axios" ) ;
71
+ mockedAxios . get . mockImplementation ( ( ) => Promise . resolve ( payload ) ) ;
72
+ } ) ;
73
+ beforeEach ( ( ) => {
74
+ jest . clearAllMocks ( ) ;
75
+ } ) ;
76
+
8
77
test ( "it render the HOME page" , async ( ) => {
9
78
render (
10
79
< React . Suspense fallback = { < span > Loading...</ span > } >
0 commit comments