Testing javascript alerts with Jasmine
var oldalert = alert;
alert = jasmine.createSpy();
// do something
expect(alert).toHaveBeenCalledWith('message')
alert = oldalert
spyOn(window, 'alert');
. . .
expect(window.alert).toHaveBeenCalledWith('a message');