Can anyone help me find out why bar is still set to null?
describe("A spy", function () {
var foo, bar = null;
beforeEach(function () {
foo = {
setRandomNum: function (value) {
bar = value
}
};
spyOn(foo, 'setRandomNum');
});
it('should return a random number', function () {
// Arrange
var randomNum = Math.random();
// Act
foo.setRandomNum(randomNum);
// Assert
expect(foo.setRandomNum).toHaveBeenCalledWith(randomNum);
expect(bar).toEqual(randomNum);
});
});