Skip to content

Commit

Permalink
Minor error in friends list solved
Browse files Browse the repository at this point in the history
  • Loading branch information
UO287687 committed Apr 27, 2024
1 parent f426adc commit 48b1795
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
10 changes: 1 addition & 9 deletions webapp/src/components/Friends.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}, []);

Expand Down
7 changes: 4 additions & 3 deletions webapp/src/test/Friends.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<IntlProvider locale={"en"} messages={messages_en}>
<SessionContext.Provider value={{ sessionData: { username: 'testUser', token: 'testToken' } }}>
Expand All @@ -24,9 +27,7 @@ describe('Friends', () => {
</IntlProvider>
);

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');
Expand Down

0 comments on commit 48b1795

Please sign in to comment.