kadamwhite/twentyfourteen-enhanced-image-nav — pull request #1 by kadamwhite (2013-11-28 22:12:12+00:00)
Title: Test original twentyfourteen navigation logic

The navigation in this script happens through `window.location` assignment, not a method call, which we can't spy on with Sinon. In order to verify that this script is working correctly from the tests, we have two options:

1. either refactor to expose the navigation logic as something we can stub out (the easier approach, which we took here), or else
2. refactor the script so that `window` is passed in by reference, allowing us to pass a mock object instead for a sort of light-weight dependency injection.

The latter approach is better-suited to situations where your entire application is built modularly, e.g. with [RequireJS](http://requirejs.org/); in fact, the [Squire.js](https://github.com/iammerrick/Squire.js/) library exists specifically to enable dependency injection for Require modules, and the [AngularJS](http://angularjs.org/) framework is designed from the ground up to enable idiomatic dependency injection.

For the purposes of our plugin, and in fact most themes and plugins, the easiest route out is to create a global namespace and access functionality through that namespace. Here, that means that we create a `TwentyFourteen` global object, and put the actual URL redirection into a stub-able function `.navigate()`.