Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Tests for a fictional hangman game, with groups
describe('Hangman - Implements the flow of a single Hangman game, given a secret word.', () => {
describe('Generates Hints from the secret word and the input', () => {
it('returns a hint that contains only underscores at the start of the game', () => { /* ... */});
['test', 'a', 'few', 'cases'].forEach(secretWord => {
it('shows a hint with the correct length for the secret word "'+secretWord+'" at the start of the game', () => {
/* ... */
});
});
[[['c'], 'c____'], [['c', 's'], 'c_s_s'], [['c', 's', 'e'], 'c_ses']].forEach(data => {
it('updates hint to "'+data[1]+'" after guessing "'+data[0]+'" when word is "cases"', () => {
/* ... */
});
});
it('does not update the hint when making a wrong guess', () => {
/* ... */
});
});
describe('Keeps track of remaining guesses, so UI can draw the gallows pole', () => {
it('decrements the number of remaining tries after a wrong guess', () => {
/* ... */
});
it('does not decrement the number of wrong guesses after a right guess', () => {
/* ... */
});
});
describe('Keeps track of whether the game is running or over (Won / Lost', () => {
it('indicates game is over ("Lost") when there was only one guess remaining and the user guessed wrong', () => {
/* ... */
});
it('indicates game is over ("Won") when the user guessed all letters of the secret word', () => {
/* ... */
});
it('does not accept any input after the game is over', () => {
/* ... */
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment