Skip to content

Commit

Permalink
new gw & stats tests
Browse files Browse the repository at this point in the history
  • Loading branch information
angelalvaigle committed Jan 4, 2025
1 parent 15e5b5e commit 62b24ce
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
13 changes: 10 additions & 3 deletions gatewayservice/gateway-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ axios.get = jest.fn((url) => {
right: 'test',
},
});
} else if (url.href.endsWith('/stats')) {
} else if (url.href.endsWith('/stats') || url.href.endsWith('/user-stats')) {
return Promise.resolve({
data: {
right: true,
Expand Down Expand Up @@ -157,7 +157,7 @@ describe('Gateway Service', () => {
});

// Test /addstat endpoint
it('should forward add question request to question service', async () => {
it('should forward add stat request to stat service', async () => {
const response = await request(app).post('/addstat').send({
right: true,
time: 7,
Expand All @@ -168,9 +168,16 @@ describe('Gateway Service', () => {
});

// Test /stats endpoint
it('should forward questions request to question service', async () => {
it('should forward stats request to stat service', async () => {
const response = await request(app).get('/stats');
expect(response.statusCode).toBe(200);
expect(response.body.right).toBe(true);
});

// Test /user-stats endpoint
it('should forward user-stats request to statn service', async () => {
const response = await request(app).get('/user-stats');
expect(response.statusCode).toBe(200);
expect(response.body.right).toBe(true);
});
});
5 changes: 5 additions & 0 deletions statservice/stat-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@ describe('Stat Service', () => {
const response = await request(app).get('/stats');
expect(response.status).toBe(200);
});

it('should get stats on GET /user-stats', async () => {
const response = await request(app).get('/user-stats');
expect(response.status).toBe(200);
});
});
1 change: 0 additions & 1 deletion webapp/src/pages/Profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { FormRow } from '../components';
import Wrapper from '../assets/wrappers/DashboardFormPage';
import { useDashboardContext } from './DashboardLayout';
import { Snackbar } from '@mui/material';
// import { Form } from 'react-router-dom';

const Profile = () => {
const { user } = useDashboardContext();
Expand Down

0 comments on commit 62b24ce

Please sign in to comment.