diff --git a/src/card.js b/src/card.js index e69de29bb..0d71ff40a 100644 --- a/src/card.js +++ b/src/card.js @@ -0,0 +1,22 @@ +function createCard(id, question, answers, correctAnswer){ + card = { + id: id, + question: question, + answers: answers, + correctAnswer: correctAnswer + } + return card +} + +function evaluateGuess(guess, correctAnswer){ + if (guess === correctAnswer){ + return 'Correct!' + } else { + return 'Incorrect :(' + } +} + +module.exports = { + createCard, + evaluateGuess +} \ No newline at end of file diff --git a/test/card-test.js b/test/card-test.js index 3396d91d4..f8ae4d307 100644 --- a/test/card-test.js +++ b/test/card-test.js @@ -1,14 +1,14 @@ const chai = require('chai'); const expect = chai.expect; -const { createCard } = require('../src/card'); +const { createCard, evaluateGuess } = require('../src/card'); describe('card', function() { - it.skip('should be a function', function() { + it('should be a function', function() { expect(createCard).to.be.a('function'); }); - it.skip('should create a card and its properties', function() { + it('should create a card and its properties', function() { const card = createCard(1, 'What allows you to define a set of related information using key-value pairs?', ['object', 'array', 'function'], 'object'); expect(card.id).to.equal(1); @@ -17,3 +17,21 @@ describe('card', function() { expect(card.correctAnswer).to.equal('object'); }); }); + +describe('turn', function() { + it('should be a function', function() { + expect(evaluateGuess).to.be.a('function'); + }) + it('should return correct when guess is correct', function() { + const guess = "array" + const correctAnswer = "array" + const result = evaluateGuess(guess, correctAnswer) + expect(result).to.equal('Correct!') + }) + it('shoudl return incorrect if the guess is not the correct answer', function() { + const guess = "object" + const correctAnswer = "array" + const result = evaluateGuess(guess, correctAnswer) + expect(result).to.equal("Incorrect :(") + }) +})