Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creando test de servicios sin funcionalidad #147

Merged
merged 6 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions questions/creationservice/creation-service.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const request = require('supertest');
const { MongoMemoryServer } = require('mongodb-memory-server');

let mongoServer;
let app;

beforeAll(async () => {
mongoServer = await MongoMemoryServer.create();
const mongoUri = mongoServer.getUri();
process.env.MONGODB_URI = mongoUri;
app = require('./creation-service');
});

afterAll(async () => {
app.close();
await mongoServer.stop();
});

describe('Retrieve Service', () => {
it('should add a new user on GET /createquestion', async () => {

const response = await request(app).get('/createquestion');
expect(response.status).toBe(200);
});
});
25 changes: 25 additions & 0 deletions questions/retrieveservice/retrieve-service.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const request = require('supertest');
const { MongoMemoryServer } = require('mongodb-memory-server');

let mongoServer;
let app;

beforeAll(async () => {
mongoServer = await MongoMemoryServer.create();
const mongoUri = mongoServer.getUri();
process.env.MONGODB_URI = mongoUri;
app = require('./retrieve-service');
});

afterAll(async () => {
app.close();
await mongoServer.stop();
});

describe('Retrieve Service', () => {
it('should add a new user on GET /getquestionshistory', async () => {

const response = await request(app).get('/getquestionshistory');
expect(response.status).toBe(200);
});
});
6 changes: 0 additions & 6 deletions webapp/src/components/MainPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ describe('MainPage component', () => {
const element1 = screen.getByText(/¡Bienvenido a/);
const element2 = screen.getByText(/WIQ 2024!/);
const newGameButton = screen.getByRole('button', { name: 'Nuevo juego' });
const historicalQuestionsButton = screen.getByRole('button', { name: 'Historial de preguntas' });
const historialUserDataButton = screen.getByRole('button', { name: 'Historial de usuario' });
const registerUsersButton = screen.getByRole('button', { name: 'Usuarios registrados' });

// Verifica si el elemento se encuentra en el DOM
expect(element1).toBeInTheDocument();
Expand All @@ -32,9 +29,6 @@ describe('MainPage component', () => {
// Simulate user input
await act(async () => {
fireEvent.click(newGameButton);
fireEvent.click(historicalQuestionsButton);
fireEvent.click(historialUserDataButton);
fireEvent.click(registerUsersButton);
});
});
});
Expand Down