From 03792303d1bea89babca48943060135e095ea6a1 Mon Sep 17 00:00:00 2001 From: Shay Hoffman Date: Thu, 1 Feb 2018 20:51:46 -0600 Subject: [PATCH] initial commit --- 02week/tests.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) 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(); + +}