functional js function spies