diff --git a/webapp/src/components/Friends.jsx b/webapp/src/components/Friends.jsx index 99660fab..f5d3f3eb 100644 --- a/webapp/src/components/Friends.jsx +++ b/webapp/src/components/Friends.jsx @@ -29,15 +29,7 @@ const Friends = ({goTo}) => { }; useEffect(() => { - const handleLoad = () => { - fetchData(); - }; - - window.addEventListener('load', handleLoad); - - return () => { - window.removeEventListener('load', handleLoad); - }; + fetchData(); //eslint-disable-next-line }, []); diff --git a/webapp/src/test/Friends.test.js b/webapp/src/test/Friends.test.js index 1246640e..896e352e 100644 --- a/webapp/src/test/Friends.test.js +++ b/webapp/src/test/Friends.test.js @@ -16,6 +16,9 @@ describe('Friends', () => { }); test('renders the friend list', async () => { + mockAxios.onGet('http://localhost:8000/getFriends/testUser').reply(200, + { friends: ['friend1', 'friend2', 'friend3', 'friend4'] } + ); render( @@ -24,9 +27,7 @@ describe('Friends', () => { ); - mockAxios.onGet('http://localhost:8000/getFriends/testUser').reply(200, - { friends: ['friend1', 'friend2', 'friend3', 'friend4'] } - ); + // Wait for the friends to be fetched await screen.findByText('friend1');