dimanche 29 avril 2018

Jasmine test doesn't create a new instance of a class

I'm trying to apply a Jasmine test to my JS program (just a game) and it doesn't create new instances for some reason. Maybe some of you can help me find the error.

'use strict';


describe('logic(bingo)',function() {
    var bin
    beforeEach(function() {
        bin = new Bingo('Alex')
    })

    it('should throw error if name is not a string',function() {
        bin=new Bingo()
        expect(function() {
            return bin.name
        }).toThrowError('Input a string name')
    })

    it('should board.length===3 and board[0].length===5',function() {
        expect(bin.board.length).toBe(3)
        expect(bin.board[0].length).toBe(5)
    })
    }

bin doesn't store a "new Bingo". It keeps being undefined. This class Bingo is declared in a different file, the links are correct.

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire