-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Created by JetBrains WebStorm. | ||
* User: craigbrookes | ||
* Date: 18/03/2012 | ||
* Time: 11:33 | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
var piece = require('./piece'); | ||
var util = require('util'); | ||
|
||
function King (opts) { | ||
piece.Piece.apply(this,[opts]); //equiv of calling super(opts) | ||
}; | ||
|
||
util.inherits(King,piece.Piece); //extend inherit from piece | ||
|
||
|
||
//override of take method | ||
|
||
King.prototype.take = function (){ | ||
console.log("king taking"); | ||
} | ||
|
||
//add king only methods | ||
|
||
exports.King = King; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Created by JetBrains WebStorm. | ||
* User: craigbrookes | ||
* Date: 18/03/2012 | ||
* Time: 11:41 | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
var assert = require('assert'); | ||
var piece = require('../server/models/piece.js'); | ||
var king = require('../server/models/king.js'); | ||
|
||
describe("normal piece creation", function () { | ||
it("should create a normal piece with type man", function () { | ||
var redpiece = new piece.Piece({side:'red'}); | ||
console.log(redpiece.toString()); | ||
assert.equal("red",redpiece.side); | ||
assert.equal('man', redpiece.type); | ||
}); | ||
}); | ||
|
||
describe("king peice creation inherits piece", function () { | ||
it("should create a king that inherits methods from piece", function () { | ||
var aking = new king.King({side:'red'}); | ||
assert.equal("red",aking.side); //test inherited property | ||
assert(true,aking.hasOwnProperty('take')); | ||
}); | ||
}); |