Here is the function I am testing:
Utilities.js
exports.calculateAgeTimeStamp = function(timestamp) {
//get year
var userYear = new Date(timestamp * 1000);
min = userYear.getFullYear();
//get current year
var curYear = new Date();
max = curYear.getFullYear();
//work out age from current year
return Math.abs(max - min);
};
It takes a timestamp and calculates age.
Here is my spec:
//test to see if timestamp converts to age.
it("timestamp should be converted to age > 20503539200", function() {
//matcher
expect(utilities.calculateAgeTimeStamp("20503539200")).toBeNumber();
});
Here is the error:
[INFO] : . - timestamp should be converted to age > 20503539200 (FAILED)
[INFO] : . - - TypeError: 'undefined' is not a function (evaluating 'expect(utilities.calculateAgeTimeStamp("20503539200")).toBeNumber()') in file:///Users/iPhone%20Simulator/7.1-64/Applications/F0A42483-4497-4670-AFEE-839D81C2E075/specs/lib/utilities_spec.js (line 12)
[INFO] : . ============================================================
[ERROR] : . THERE WERE FAILURES!
[ERROR] : . ============================================================
[ERROR] : . Recap of failing specs:
[ERROR] : . ------------------------------------------------------------
[ERROR] : . utilities timestamp should be converted to age > 20503539200. - TypeError: 'undefined' is not a function (evaluating 'expect(utilities.calculateAgeTimeStamp("20503539200")).toBeNumber()')
I know this function works, because it is working fine in my app. Any idea why I am getting this error, cheers.