Skip to content
This repository has been archived by the owner on Dec 7, 2017. It is now read-only.

Commit

Permalink
fix broken test; add test for look
Browse files Browse the repository at this point in the history
  • Loading branch information
siuying committed Sep 2, 2011
1 parent 0699169 commit dc03eba
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
@@ -1,8 +1,8 @@
vows = require('vows') vows = require('vows')
assert = require('assert') assert = require('assert')


{_} = require('../vendor/underscore') {_} = require('underscore')
{JsWarrior} = require('../lib/js_warrior') {JsWarrior} = require('../../lib/js_warrior')


vows.describe('Base').addBatch( vows.describe('Base').addBatch(
'with empty space': 'with empty space':
Expand Down
33 changes: 33 additions & 0 deletions 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);
2 changes: 1 addition & 1 deletion test/level_loader_spec.coffee
Expand Up @@ -66,6 +66,6 @@ vows.describe('LevelLoader').addBatch(
assert.equal(level.timeBonus, 15) assert.equal(level.timeBonus, 15)
assert.equal(level.aceScore, 10) 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.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); ).export(module);
6 changes: 3 additions & 3 deletions test/level_test.coffee
Expand Up @@ -5,7 +5,7 @@ assert = require('assert')
{JsWarrior} = require('../lib/js_warrior') {JsWarrior} = require('../lib/js_warrior')


vows.describe('Floor').addBatch( vows.describe('Floor').addBatch(
'Initialize': 'Floor':
'topic': -> 'topic': ->
profile = new JsWarrior.Profile() profile = new JsWarrior.Profile()
floor = new JsWarrior.Floor(1) floor = new JsWarrior.Floor(1)
Expand All @@ -31,10 +31,10 @@ vows.describe('Floor').addBatch(
assert.equal(_.keys(level.warrior.getAbilities()).indexOf('attack') > -1, true) assert.equal(_.keys(level.warrior.getAbilities()).indexOf('attack') > -1, true)


"should setup warrior name with profile name": ({profile, level}) -> "should setup warrior name with profile name": ({profile, level}) ->
profile.warrior_name = "Joe" profile.warriorName = "Joe"
level.warrior = new JsWarrior.Units.Warrior() level.warrior = new JsWarrior.Units.Warrior()
level.setupWarrior(level.warrior) level.setupWarrior(level.warrior)
assert.equal(level.warrior.name, "Joe") assert.equal(level.warrior.name(), "Joe")


'Attempt loading non existing level': 'Attempt loading non existing level':
'topic': -> 'topic': ->
Expand Down

0 comments on commit dc03eba

Please sign in to comment.