generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/Arquisoft/wiq_en2a
- Loading branch information
Showing
7 changed files
with
175 additions
and
10 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
global: | ||
scrape_interval: 5s | ||
scrape_configs: | ||
- job_name: "example-nodejs-app" | ||
- job_name: "conoceryvencer-nodejs-app" | ||
static_configs: | ||
- targets: ["gatewayservice:8000"] | ||
- targets: ["gatewayservice:8000","userservice:8001","queryservice:8002","gatewayservice:8003","gameservice:8004"] |
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,73 @@ | ||
import React from 'react'; | ||
import { render, fireEvent, waitFor } from '@testing-library/react'; | ||
import PlayingGame from './PlayingGame'; | ||
|
||
jest.useFakeTimers(); | ||
|
||
describe('PlayingGame component', () => { | ||
it('should handle answering questions and end game correctly', async () => { | ||
const questions = [ | ||
{ uuid: '1', | ||
question: 'What is the capital of France?', | ||
correctAnswer: '1', | ||
incorrectAnswer1: '2', | ||
incorrectAnswer2: '3', | ||
incorrectAnswer3: '4', }, | ||
{ uuid: '2', | ||
question: 'What is the capital of Italy?', | ||
correctAnswer: '1', | ||
incorrectAnswer1: '2', | ||
incorrectAnswer2: '3', | ||
incorrectAnswer3: '4', }, | ||
{ uuid: '2', | ||
question: 'What is the capital of Spain?', | ||
correctAnswer: '1', | ||
incorrectAnswer1: '2', | ||
incorrectAnswer2: '3', | ||
incorrectAnswer3: '4', }, | ||
]; | ||
|
||
const setCurrentStageMock = jest.fn(); | ||
const { getByTestId, queryByTestId } = render( | ||
<PlayingGame | ||
questions={questions} | ||
setCurrentStage={setCurrentStageMock} | ||
/> | ||
); | ||
|
||
// Ensure initial rendering | ||
expect(getByTestId('question-container')).toBeInTheDocument(); | ||
expect(getByTestId('question-title')).toBeInTheDocument(); | ||
expect(getByTestId('question')).toBeInTheDocument(); | ||
expect(getByTestId('seconds')).toBeInTheDocument(); | ||
|
||
// Simulate answering question 1 | ||
fireEvent.click(getByTestId('answer-1')); | ||
jest.advanceTimersByTime(10000); | ||
await waitFor(() => { | ||
expect(getByTestId('question-title')).toBeInTheDocument(); | ||
expect(getByTestId('question')).toBeInTheDocument(); | ||
expect(getByTestId('seconds')).toHaveTextContent('10'); | ||
|
||
}); | ||
|
||
// Simulate answering question 2 | ||
fireEvent.click(getByTestId('answer-2')); | ||
jest.advanceTimersByTime(10000); | ||
await waitFor(() => { | ||
expect(getByTestId('question')).toBeInTheDocument(); | ||
expect(getByTestId('seconds')).toHaveTextContent('10'); | ||
}); | ||
|
||
// Simulate answering question 3 | ||
fireEvent.click(getByTestId('answer-3')); | ||
jest.advanceTimersByTime(10000); | ||
await waitFor(() => { | ||
expect(queryByTestId('question-container')).toBeNull(); | ||
expect(getByTestId('result')).toBeInTheDocument(); | ||
expect(getByTestId('points')).toHaveTextContent('playing_single_player_you_earned50playing_single_player_points'); | ||
}); | ||
}); | ||
|
||
// Add more test cases for edge cases and multiplayer scenarios if applicable | ||
}); |
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
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