Mockjax Test

This test illustrates a bug in the Mockjax javascript library after adding the ability to have synchronous mocking if the responseTime is set to 0 in the mockjax setup.

HTML

<link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css">
<script src="http://code.jquery.com/qunit/git/qunit.js"></script>
<script src="https://github.com/robdmoore/jquery-mockjax/raw/f837ab421e481010148ac0f174e0214068a6180f/jquery.mockjax.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Test</title> 
</head>
<body>
 <h1 id="qunit-header">QUnit example</h1>
 <h2 id="qunit-banner"></h2>
 <div id="qunit-testrunner-toolbar"></div>
 <h2 id="qunit-userAgent"></h2>
 <ol id="qunit-tests"></ol>
 <div id="qunit-fixture"></div>
</body>
</html>

JavaScript

asyncTest('Response returns jsonp', function() {
    $.mockjax({
        url: 'http://search.twitter.com/search.json*',
        contentType: 'text/json',
        proxy: 'mocks/twitter.json'
    });
    window.abcdef123456 = function() {
        start();
        ok(true, 'JSONP Callback executed');
    };

    $.ajax({
        url: 'http://search.twitter.com/search.json?q=Javascript&callback=?',
        jsonpCallback: 'abcdef123456',
        dataType: 'jsonp',
        error: function() {},
        complete: function() {}
    });
    $.mockjaxClear();
});