I am testing a function which returns an object. Value of one of its key is current time in miliseconds. How can we test it using jasmine?
var fun = function(name,id){
var obj = {
name : name,
id : id,
createdTime : Date.now()
}
return obj;
}
expect(fun("abc",1)).toBe({name:"abc",id:1,createdTime:Date.now()})
Date.now()
returns 2 different values because main function & test case both runs at different time.