it('should produce alert on functional search attempt', function(){ var alertSpy = spyOn(window, 'alert').and.callFake(function(){}); var searchString = 't:admin'; //call method that displays alert expect(alertSpy).toHaveBeenCalledTimes(1); expect(alertSpy).toHaveBeenCalledWith('alert_message'); });