@@ -9,12 +9,27 @@ describe('Auth Component π', () => {
99 beforeEach ( ( ) => {
1010 originalLocation = window . location
1111 delete ( window as any ) . location
12- window . location = { ...originalLocation , reload : jest . fn ( ) } as Location
12+
13+ Object . defineProperty ( window , 'location' , {
14+ value : {
15+ ...originalLocation ,
16+ reload : jest . fn ( ) ,
17+ assign : jest . fn ( ) ,
18+ replace : jest . fn ( ) ,
19+ toString : ( ) => originalLocation . toString ( ) ,
20+ hostname : 'localhost' , // for image path logic
21+ } ,
22+ writable : true ,
23+ } )
24+
1325 localStorage . clear ( )
1426 } )
1527
1628 afterEach ( ( ) => {
17- window . location = originalLocation // Restore the original location
29+ Object . defineProperty ( window , 'location' , {
30+ value : originalLocation ,
31+ writable : true ,
32+ } )
1833 } )
1934
2035 it ( 'β
should be defined β¨' , ( ) => {
@@ -23,6 +38,7 @@ describe('Auth Component π', () => {
2338
2439 it ( 'π¨ renders the authentication form π' , ( ) => {
2540 render ( < Auth /> )
41+
2642 expect ( screen . getByText ( 'GitHub Authentication' ) ) . toBeInTheDocument ( )
2743 expect (
2844 screen . getByText (
@@ -37,6 +53,7 @@ describe('Auth Component π', () => {
3753
3854 it ( 'π― updates input fields on user input ποΈ' , ( ) => {
3955 render ( < Auth /> )
56+
4057 const usernameInput = screen . getByLabelText ( 'GitHub Username:' )
4158 const tokenInput = screen . getByLabelText ( 'GitHub Personal Access Token:' )
4259
@@ -65,6 +82,7 @@ describe('Auth Component π', () => {
6582
6683 it ( 'π contains a link to generate a GitHub token π' , ( ) => {
6784 render ( < Auth /> )
85+
6886 const link = screen . getByRole ( 'link' , {
6987 name : 'Click here to generate a New GitHub Personal Access Token' ,
7088 } )
0 commit comments