diff --git a/02week/tests.js b/02week/tests.js index e69de29bb..283bbaa1a 100644 --- a/02week/tests.js +++ b/02week/tests.js @@ -0,0 +1,34 @@ +// More JS tests for rock paper scissors + +if (typeof describe === 'function') { + + describe('#rockPaperScissors()', () => { + it('should detect a tie', () => { + assert.equal(rockPaperScissors('rock', 'rock'), "It's a tie!"); + assert.equal(rockPaperScissors('paper', 'paper'), "It's a tie!"); + assert.equal(rockPaperScissors('scissors', 'scissors'), "It's a tie!"); + }); + it('should detect which hand won', () => { + assert.equal(rockPaperScissors('rock', 'paper'), "Hand two wins!"); + assert.equal(rockPaperScissors('paper', 'scissors'), "Hand two wins!"); + assert.equal(rockPaperScissors('scissors', 'rock'), "Hand two wins!"); + assert.equal(rockPaperScissors('rock', 'scissors'), "Hand one wins!"); + assert.equal(rockPaperScissors('scissors', 'paper'), "Hand one wins!"); + assert.equal(rockPaperScissors('paper', 'rock'), "Hand one wins!"); + }); + it('should scrub input to ensure lowercase with "trim"ed whitepace', () => { + assert.equal(rockPaperScissors('rOcK', ' paper '), "Hand two wins!"); + assert.equal(rockPaperScissors('Paper', 'SCISSORS'), "Hand two wins!"); + assert.equal(rockPaperScissors('rock ', 'sCiSsOrs'), "Hand one wins!"); + }); + it('should detect whether user inputs are valid for the game', () => { + assert.equal(rockPaperScissors('true', 'false'), "User input invalid. Choose rock, paper, or scissors!"); + assert.equal(rockPaperScissors('10', 'name') "User input invalid. Choose rock, paper, or scissors!"); + assert.equal(rockPaperScissors('blank', 'pink') "User input invalid. Choose rock, paper, or scissors!"); + }); + }); +} else { + + getPrompt(); + +}