I am just getting into using Jasmine, but have spent over 2 hours without the ability to even get one test to run.
I am getting the error TypeError: object is not a function for line 7.
The weird thing is that I basically copied the format from other projects that worked fine, and I can use calc = new Calc(); within calc.js without a problem. Nothing I do here works though.
Any ideas?
Here is the ‘spec/calc_spec.js’
var Calc = require('../Calc.js');
describe("Calc", function() {
var calc;
beforeEach(function() {
calc = new Calc();
});
it("returns the max number in an array", function() {
var arr = [1,2,3,4,2,7,5];
expect(calc.my_max(arr)).toEqual(7);
});
});
And my ‘Calc.js’
var Calc = function() {};
Calc.prototype.my_max = function(nums) {
var max = 0;
for( var i=0; i<nums.length; i++ ) {
if( nums[i] > max ) max = nums[i];
}
return max;
};