generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4307c6
commit e692266
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,18 @@ describe('ForgetPassword Component', () => { | |
await expect(forgetPasswordFunctions.changePassword('[email protected]', 'testuser', 'newpassword', 'newpassword')).rejects.toThrow('Failed to change password'); | ||
}); | ||
}); | ||
|
||
describe('checkUrl', () => { | ||
it('should have base url', async () => { | ||
expect(forgetPasswordFunctions.apiUrl).toEqual('http://localhost:8000'); | ||
}); | ||
|
||
it('should have env variable url', async () => { | ||
process.env.REACT_APP_API_ENDPOINT = 'test'; | ||
forgetPasswordFunctions = new ForgetPasswordFunctions(); | ||
expect(forgetPasswordFunctions.apiUrl).toEqual('test'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import axios from 'axios'; | ||
import RankingRetriever from './RankingRetriever'; // Ruta a tu archivo RankingRetriever | ||
|
||
jest.mock('axios'); // Simula las llamadas a Axios | ||
|
||
describe('RankingRetriever Tests', () => { | ||
let rankingRetriever; | ||
|
||
beforeEach(() => { | ||
rankingRetriever = new RankingRetriever(); | ||
}); | ||
|
||
test('Throws error if endpoint is not set for getTopTen', async () => { | ||
axios.get.mockRejectedValue(new Error('Endpoint not found')); // Simula error | ||
|
||
try { | ||
await rankingRetriever.getTopTen('dummy-token'); | ||
} catch (error) { | ||
expect(error).toBeInstanceOf(Error); // Verifica que se lanzó un error | ||
expect(error.message).toContain('Endpoint not found'); // Verifica el mensaje del error | ||
} | ||
}); | ||
|
||
test('Throws error if endpoint is not set for getUser', async () => { | ||
axios.get.mockRejectedValue(new Error('Endpoint not found')); // Simula error | ||
|
||
try { | ||
await rankingRetriever.getUser('dummy-user', 'dummy-token'); | ||
} catch (error) { | ||
expect(error).toBeInstanceOf(Error); // Verifica que se lanzó un error | ||
expect(error.message).toContain('Endpoint not found'); // Verifica el mensaje del error | ||
} | ||
}); | ||
|
||
test('should have the base url', () => { | ||
expect(rankingRetriever.apiUrl).toEqual('http://localhost:8000/record/ranking') | ||
}) | ||
|
||
test('should not have the base url', () => { | ||
process.env.REACT_APP_API_ENDPOINT = 'test'; | ||
rankingRetriever = new RankingRetriever(); | ||
expect(rankingRetriever.apiUrl).toEqual('test/record/ranking') | ||
}) | ||
}); |