here is my function
var EngineAction = function (hostUrl) {
this.parseInput = function (vinNumber, action) {
var requestedAction = ''
if (action === 'START') {
requestedAction = 'START_VEHICLE';
} else if (action === 'STOP') {
requestedAction = 'STOP_VEHICLE';
} else {
throw new Error("input action is not valid");
}
return { id: vinNumber, "action" : requestedAction };
}
}
}
Here is mocha test:
it('throw error, input for engineAction', function(done) {
var gm = new GM ();
expect(gm.engineAction.parseInput("123", "STATR")).to.throw(Error);
gm.engineAction.parseInput("123", "STATR")).to.throw(Error);
done();
});
I have tried multiple ways but the test fails with the message
1) GM model test throw error, input for engineAction:
Error: input action is not valid
at parseInput (models/gm.js:87:15)
at Context.<anonymous> (test/gm.js:59:25)
This shows the method throws error but test is not asserting. What am i missing ?