@@ -23,6 +23,12 @@ describe("Player", function() {
23
23
it ( 'should start in position 0' , function ( ) {
24
24
expect ( player . avatar . position . x ) . toEqual ( 0 ) ;
25
25
} ) ;
26
+
27
+ it ( "should be possible to define the initial position" , function ( ) {
28
+ player = new Player ( { position : { x :360 , y :550 } } ) ;
29
+ expect ( player . avatar . position . x ) . toEqual ( 360 ) ;
30
+ expect ( player . avatar . position . y ) . toEqual ( 550 ) ;
31
+ } ) ;
26
32
27
33
it ( "should display the player's name in #hello div" , function ( ) {
28
34
$ ( '#jasmine_content' ) . html ( '<div id="hello"></div>' ) ;
@@ -70,20 +76,18 @@ describe("Player", function() {
70
76
71
77
} ) ;
72
78
73
- describe ( "on_up_arrow " , function ( ) {
79
+ describe ( "on up arrow " , function ( ) {
74
80
beforeEach ( function ( ) {
75
- var event = jQuery . Event ( 'keydown' ) ;
76
- event . keyCode = Config . key_codes . up ;
77
- $game_container . trigger ( event ) ;
81
+ simulate_up_key_press ( ) ;
78
82
} ) ;
79
83
80
84
it ( 'should change velocity on keydown' , function ( ) {
81
- expect ( player . avatar . velocity . y ) . toEqual ( 1 ) ;
85
+ expect ( player . avatar . velocity . y ) . toEqual ( AVATAR_JUMP_ACCEL ) ;
82
86
} ) ;
83
87
84
88
it ( 'should move up' , function ( ) {
85
89
game . next_tick ( ) ;
86
- expect ( player . avatar . position . y ) . toEqual ( 1 ) ;
90
+ expect ( player . avatar . position . y ) . toEqual ( AVATAR_JUMP_ACCEL + GRAVITY ) ;
87
91
} ) ;
88
92
89
93
} ) ;
0 commit comments