samedi 31 octobre 2015

'Undefined' result in Javascript testing

I am creating a Kata on Codewars. Its objective is to make a Player with certain attributes and values. This is the complete working solution,

function Player(name, position, age, dribbling, pass, shoot) {
 this.name = name;
 this.position = position;
 this.age = age;
 this.dribbling = dribbling;
 this.pass = pass;
 this.shoot = shoot;
} 

var myPlayer = new Player('Player', 'Right Winger', 25, 75, 90, 65);

And this is the Test Cases I have to provide to validate the complete working solution in order to publish the Kata,

describe('Player class', function () {
  it('should create a Player', function (){
    var myPlayer = new Player()
      Test.assertEquals(myPlayer.name, 'Player')
      Test.assertEquals(myPlayer.position, 'Right Winger')
      Test.assertEquals(myPlayer.age, 25)
      Test.assertEquals(myPlayer.dribbling, 75)
      Test.assertEquals(myPlayer.pass, 90)
      Test.assertEquals(myPlayer.shoot, 65)
    })
})`

And this is the result I get when I run the 'Validate Solution' button,

Player class
should create a Player
Expected: Player, instead got: undefined
Expected: Right Winger, instead got: undefined
Expected: 25, instead got: undefined
Expected: 75, instead got: undefined
Expected: 90, instead got: undefined
Expected: 65, instead got: undefined

0 Passed
6 Failed
0 Errors

What am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire