Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions 02week/tests.js
Original file line number Diff line number Diff line change
@@ -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();

}