Created
February 12, 2014 21:56
-
-
Save CooperAtive/8965338 to your computer and use it in GitHub Desktop.
Object Testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.Card = function(suit, rank) { | |
function contructor() {}; | |
constructor.prototype.getRank = function() { return rank; }; | |
constructor.prototype.getSuit = function() { return suit; }; | |
return new constructor(); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
'use strict'; | |
}()); | |
var Card = require('../lib/Card.js').Card, | |
expect = require('chai').expect; | |
describe('Card object test:', function() { | |
var card; | |
beforeEach( function() { | |
card = new Card('spades', 'Ace'); | |
}); | |
describe('constructor', function() { | |
it('Card should be truthy (exists)', function() { | |
expect(card).to.be.ok; | |
}); | |
it('getSuit equals the card\'s suit', function() { | |
expect(Card.getSuit()).to.equal('spades'); | |
}); | |
it('getRank equals the card\'s suit', function() { | |
expect(Card.getRank()).to.equal('Ace'); | |
}); | |
it('can\'t change the card\'s suit', function() { | |
card.suit = "Cooper"; | |
expect(card.getSuit()).to.not.equal("Cooper"); | |
}); | |
it('can\'t change the card\'s rank', function() { | |
card.rank = "Colonel"; | |
expect(card.getSuit()).to.not.equal("Colonel"); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment