Week 5, day 3

We've been continuing with Javascript and Jquery today. Javascript is surprisingly easy to pick up after all our Ruby training, which is definitely good news.
The only thing I'm challenged by at the moment is getting JS deployed to the web but my goal is to change that before this weekend.

$(document).ready(function(){
  $('div').mouseenter(function(){
    $('div').fadeTo('fast', 1);
  });
  $('div').mouseleave(function(){
    $('div').fadeTo('fast', 0.5);
  });
});

A Jquery function to fade a button in on mouseover and off when you leave it.

Another revelation from today is about stubbing functions in JS. What we figured out yesterday applies to doubling foreign objects in a unit test and mocking their behaviour, but the same syntax doesn't apply to stubbing behaviour for objects that you are testing directly.

spyOn(airport, "isWeatherGood").and.callFake(function() {
  return false;
});

And that's how you do it.
In other news I comfortably finished off my port of Airport challenge into Javascript and feel pretty confident about tackling the rest of my planned rewrites.

Written on April 15, 2015