Hey,
I'm kinda new to the whole JavaScript shenanigans, but I'm quite experienced with various languages.
I'm used to, and would prefer, writing unit tests for my code, before writing the actual code. I have set up Mocha, and it seems to be working correctly. My issue is now that I can't test code that uses any Screeps function, since those are hidden away.
I've never had to write tests for code outside of the environment, so to say. Is it possible to somehow work around this?
I've made a function,
RoomPosition.prototype.getAdjacent = function(direction) { ... }
Which takes a direction and returns the adjacent position in that direction. Now my issue is that I can't test this.
It seems logical to do something like this:
var assert = require('chai').assert;
require('../../src/prototypes/prototype.RoomPosition')();
describe('RoomPosition', function() {
describe('#getAdjacent(direction)', function() {
it('should return a new RoomPosition moved in the direction', function() {
var pos = new RoomPosition(1, 1, 'TestingRoom');
assert.equal(pos.getAdjacent(TOP), new RoomPosition(1, 0, 'TestingRoom'));
});
});
});
But, then I'd need to be able to somehow inject the constructor for RoomPosition, and also the values for the direction constants.
Any help would be appreciated!