Skip to content

Commit

Permalink
Add toast messages & allow for no time limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamesllllllllll committed Jun 2, 2024
1 parent 5760f4c commit 38e570b
Show file tree
Hide file tree
Showing 21 changed files with 580 additions and 427 deletions.
34 changes: 34 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"react-dom": "^18",
"react-flip-move": "^3.0.5",
"react-flip-toolkit": "^7.1.0",
"react-hot-toast": "^2.4.1",
"react-hotkeys-hook": "^4.5.0",
"uuid": "^9.0.1"
},
"devDependencies": {
Expand Down
44 changes: 31 additions & 13 deletions src/app/__tests__/new-game-form.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ global.fetch = jest.fn(() =>
})
);

describe('New Game Form', () => {
describe.only('New Game Form', () => {
it('renders all inputs', () => {
const { getByLabelText } = render(<NewGameForm />);

Expand Down Expand Up @@ -85,7 +85,7 @@ describe('Handle form inputs and submission', () => {
expect(timeLimit.value).toBe('1800');
});

it('Adds inputs to challenges', async () => {
it.only('Adds inputs to challenges', async () => {
const {
getByLabelText,
getAllByLabelText,
Expand All @@ -96,6 +96,8 @@ describe('Handle form inputs and submission', () => {
const user = userEvent.setup();

// Add Trivia clue
const addtriviaButton = getByTestId('add-trivia-challenge');
await user.click(addtriviaButton);
const triviaClue = getByLabelText('Question (required)');
await user.click(triviaClue);
await user.keyboard('Trivia question #1');
Expand All @@ -105,6 +107,10 @@ describe('Handle form inputs and submission', () => {
await user.keyboard('Trivia answer #1');

// Add Cryptogram description
const cryptogramLabel = getByTestId('add-cryptogram');
await user.click(cryptogramLabel);
const addCryptogramButton = getByTestId('add-cryptogram-challenge');
await user.click(addCryptogramButton);
const cipherDesc = getByTestId('challenge-1-cryptogram-answer');
await user.click(cipherDesc);
await user.keyboard('Decrypt this phrase');
Expand All @@ -115,6 +121,10 @@ describe('Handle form inputs and submission', () => {
expect(cipherClue.value).not.toBeNull();

// Add Word Scramble description & answer
const wordScrambleLabel = getByTestId('add-cryptogram');
await user.click(wordScrambleLabel);
const addWordScrambleButton = getByTestId('add-word-scramble-challenge');
await user.click(addWordScrambleButton);
const scrambleDescription = getByPlaceholderText(
'Describe the phrase to be solved'
);
Expand Down Expand Up @@ -235,22 +245,30 @@ it('Adds a FITB challenge and renders the answer & clues', async () => {
const addChallengeButton = getByTestId('add-fill-in-the-blank-challenge');
await user.click(addChallengeButton);

const answer = getByTestId('challenge-3-fill-in-the-blank-answer')
await user.click(answer)
await user.keyboard('Challenge answer with blank spaces')
const answer = getByTestId('challenge-3-fill-in-the-blank-answer');
await user.click(answer);
await user.keyboard('Challenge answer with blank spaces');

// Remove a word - expect a blank space and
const wordToRemove = getByTestId('challenge-3-fill-in-the-blank-highlight-word-3')
await user.click(wordToRemove)
const blank = getByText('________')
const wordToRemove = getByTestId(
'challenge-3-fill-in-the-blank-highlight-word-3'
);
await user.click(wordToRemove);
const blank = getByText('________');
expect(blank).toBeInTheDocument();
const correctClueWord = getByTestId('challenge-3-fill-in-the-blank-correct-clue-word-3')
const correctClueWord = getByTestId(
'challenge-3-fill-in-the-blank-correct-clue-word-3'
);
expect(correctClueWord).toBeInTheDocument();

const incorrectWordInput = getByTestId('challenge-3-fill-in-the-blank-incorrect-words')
await user.click(incorrectWordInput)
await user.keyboard('incorrect, words')
const incorrectClueWord = getByTestId('challenge-3-fill-in-the-blank-incorrect-clue-word-0')
const incorrectWordInput = getByTestId(
'challenge-3-fill-in-the-blank-incorrect-words'
);
await user.click(incorrectWordInput);
await user.keyboard('incorrect, words');
const incorrectClueWord = getByTestId(
'challenge-3-fill-in-the-blank-incorrect-clue-word-0'
);
expect(incorrectClueWord).toBeInTheDocument();
});

Expand Down
2 changes: 1 addition & 1 deletion src/app/components/challenges/Trivia.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function TriviaChallenge({
<p className='text-center font-bold text-xl' data-type='challenge-submit'>{currentChallenge.clue}</p>
<form
onSubmit={handleSubmit}
className='flex flex-col gap-2 items-center gap-8'
className='flex flex-col items-center gap-8'
>
<Input
fieldType='text'
Expand Down
Loading

0 comments on commit 38e570b

Please sign in to comment.