Skip to content

Instantly share code, notes, and snippets.

@dtanzer
Created July 3, 2017 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dtanzer/63d619c1797edfcde54bd2dc5573a1c8 to your computer and use it in GitHub Desktop.
Save dtanzer/63d619c1797edfcde54bd2dc5573a1c8 to your computer and use it in GitHub Desktop.
Tests for a fictional implementation of a hangman game
describe('Hangman - Implements the flow of a single Hangman game, given a secret word.', () => {
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', () => {
/* ... */
});
it('decrements the number of remaining tries after a wrong guess', () => {
/* ... */
});
it('does not decrement the number of wrong guesses after a right guess', () => {
/* ... */
});
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