1
0
mirror of https://github.com/exane/not-gwent-online synced 2025-08-13 13:07:32 +00:00

lot of stuff

This commit is contained in:
exane
2015-06-21 16:50:50 +02:00
parent 66cc04d36c
commit 753f4e7a9c
19 changed files with 1155 additions and 102 deletions

13
test/src/CardSpec.js Normal file

@@ -0,0 +1,13 @@
var Card = require("../../server/Card");
describe("cards", function(){
var card;
beforeEach(function() {
card = Card("john_natalis");
});
it("should have hero ability", function() {
expect(card.hasAbility("hero")).toBe(true);
})
})

@@ -94,5 +94,37 @@ describe("pubsub", function(){
expect(battle.events).toEqual({});*/
})
it("should give binded ctx", function() {
var obj = {}, otherCtx = { key: "test"};
var card = Card("biting_frost");
var ability = card.getAbility();
obj.setWeather = function(weatherType) {
expect(weatherType).toEqual(0);
expect(this).toBe(otherCtx);
}
spyOn(obj, "setWeather").and.callThrough();
expect(ability.weather).toBeDefined();
ability.onEachTurn = obj.setWeather.bind(otherCtx, ability.weather);
ability.onEachCardPlace = obj.setWeather.bind(otherCtx, ability.weather);
if(ability.onEachTurn){
var uid = battle.on("EachTurn", ability.onEachTurn, battle, [card])
card._uidEvents["EachTurn"] = uid;
}
if(ability.onEachCardPlace){
var uid = battle.on("EachCardPlace", ability.onEachCardPlace, battle, [card]);
card._uidEvents["EachCardPlace"] = uid;
}
battle.runEvent("EachCardPlace");
battle.runEvent("EachTurn");
expect(obj.setWeather).toHaveBeenCalled();
})
});

@@ -1,5 +1,6 @@
require("./filterSpec");
require("./PubSubSpec");
require("./CardSpec");
(function main(){