Skip to content
Browse files

fix broken test; add test for look

  • Loading branch information...
1 parent 0699169 commit dc03ebada118d91e5d2114c48edd88d0a40547cf @siuying committed Sep 2, 2011
View
4 test/base_unit_test.coffee → test/abilities/base_unit_test.coffee
@@ -1,8 +1,8 @@
vows = require('vows')
assert = require('assert')
-{_} = require('../vendor/underscore')
-{JsWarrior} = require('../lib/js_warrior')
+{_} = require('underscore')
+{JsWarrior} = require('../../lib/js_warrior')
vows.describe('Base').addBatch(
'with empty space':
View
33 test/abilities/look_test.coffee
@@ -0,0 +1,33 @@
+vows = require('vows')
+assert = require('assert')
+{_} = require('underscore')
+{JsWarrior} = require('../../lib/js_warrior')
+
+vows.describe('Look').addBatch(
+ 'Looking':
+ 'topic': ->
+ profile = new JsWarrior.Profile()
+ level = new JsWarrior.Level(profile, 1)
+ loader = new JsWarrior.LevelLoader(level)
+ profile: profile
+ level: level
+ loader: loader
+
+ "should get 3 objects at position from offset": ({loader, level, profile}) ->
+ loader.size(8, 1)
+ unit1 = loader.unit('archer', 1, 0, 'east')
+ unit2 = loader.unit('captive', 2, 0, 'west')
+ unit3 = loader.unit('sludge', 3, 0, 'west')
+ unit4 = loader.unit('wizard', 4, 0, 'west')
+
+ [s2, s3, s4] = unit1.abilities['look'].perform('forward')
+ assert.equal(s2.getUnit().name(), 'Captive')
+ assert.equal(s3.getUnit().name(), 'Sludge')
+ assert.equal(s4.getUnit().name(), 'Wizard')
+
+ [s3, s2, s1] = unit4.abilities['look'].perform('forward')
+ assert.equal(s3.getUnit().name(), 'Sludge')
+ assert.equal(s2.getUnit().name(), 'Captive')
+ assert.equal(s1.getUnit().name(), 'Archer')
+
+).export(module);
View
2 test/level_loader_spec.coffee
@@ -66,6 +66,6 @@ vows.describe('LevelLoader').addBatch(
assert.equal(level.timeBonus, 15)
assert.equal(level.aceScore, 10)
assert.equal(level.description, "You see before yourself a long hallway with stairs at the end. There is nothing in the way.")
- assert.equal(level.tip, "Call warrior.walk to walk forward in the Player 'play_turn' method.")
+ assert.equal(level.tip, "Call warrior.walk() to walk forward in the Player 'playTurn()' method.")
).export(module);
View
6 test/level_test.coffee
@@ -5,7 +5,7 @@ assert = require('assert')
{JsWarrior} = require('../lib/js_warrior')
vows.describe('Floor').addBatch(
- 'Initialize':
+ 'Floor':
'topic': ->
profile = new JsWarrior.Profile()
floor = new JsWarrior.Floor(1)
@@ -31,10 +31,10 @@ vows.describe('Floor').addBatch(
assert.equal(_.keys(level.warrior.getAbilities()).indexOf('attack') > -1, true)
"should setup warrior name with profile name": ({profile, level}) ->
- profile.warrior_name = "Joe"
+ profile.warriorName = "Joe"
level.warrior = new JsWarrior.Units.Warrior()
level.setupWarrior(level.warrior)
- assert.equal(level.warrior.name, "Joe")
+ assert.equal(level.warrior.name(), "Joe")
'Attempt loading non existing level':
'topic': ->

0 comments on commit dc03eba

Please sign in to comment.
Something went wrong with that request. Please try again.