JSFiddle - React, Tailwind, and code Playground

by aknuds1

HTML

<script src="http://pivotal.github.com/jasmine/lib/jasmine.js"></script>
<script src="http://pivotal.github.com/jasmine/lib/jasmine-html.js"></script>
<link rel="stylesheet" href="http://pivotal.github.com/jasmine/lib/jasmine.css">

JavaScript

/* Start library code */
var lib = (function() {
    function navigate(path) {
        history.pushState(null, null, path);
    }

    function onPopState(event) {
        if (lib.callback) {
            lib.callback(document.location);
        }
    }

    $(window).bind('popstate', onPopState);

    return {
        navigate: navigate
    };
})();

/* End library code */

/* Begin test code */
describe("Test navigate", function() {
    it("Should invoke callback upon state change", function() {
        var invokedWith;
        function callback(url) {
            invokedWith = url;
        }
        lib.callback = callback;
        lib.navigate('/path');
        // Doesn't work, callback invoked asynchronously
        expect(invokedWith).toEqual('/path');
    });
});

var env = jasmine.getEnv();
env.updateInterval = 250;
var htmlReporter = new jasmine.HtmlReporter();
env.addReporter(htmlReporter);
env.specFilter = function(spec) {
    return htmlReporter.specFilter(spec);
};

env.execute();
/* End test code */