mardi 21 juin 2016

Jasmine Mocks with no functions or return values

How would one create a mock in jasmine that has no functions and does nothing?

I know this can be done in javascript easily. But for the sake of consistency I'd like to make my mocks in jasmine.

Mocks are described with different terminology in Jasmine so I'm having a hard time understanding some simple mocking practices.

I have created this mock which has a method that returns a value.

var insuranceHistoryVMMock = jasmine.createSpyObj('insuranceHistoryVM', ['getNameByCustomerId']);
        insuranceHistoryVMMock.getNameByCustomerId.and.returnValue("Bobby Bushay");

So a more simplistic mock (no functions or return values) would be something like:

var indexMock = jasmine.createSpyObj('index', ['']);

Is that the official way of doing it?

Aucun commentaire:

Enregistrer un commentaire