Created
August 1, 2012 11:49
-
-
Save distributedlife/3226161 to your computer and use it in GitHub Desktop.
How do I mock the dependency of the things under test?
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
define(["game/thing_view"], function(ThingView) { | |
return function(THREE, bullet) { | |
var _this = new ThingView(THREE, bullet, "/public/img/tank_bullet.png") | |
return _this; | |
} | |
}); |
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
requirejs = require('../spec_helper').requirejs | |
three = require('../stubs/three').three | |
ThingView = jasmine.createSpy('ThingView') | |
requirejs.define "game/thing_view", [], () -> | |
return ThingView | |
requirejs ["game/bullet_view", "game/bullet"], (BulletView, Bullet) -> | |
describe "bullet view", -> | |
bullet = new Bullet() | |
it "should create a thing view", -> | |
view = new BulletView(three, bullet) | |
expect(ThingView).toHaveBeenCalled() | |
it "should use the bullet image", -> | |
requirejs.undef("game/thing_view") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment