Skip to content

Commit

Permalink
Merge pull request #294 from jakerella/v2.2.0
Browse files Browse the repository at this point in the history
Upgrade library to v2.2.0
  • Loading branch information
jakerella authored Jun 14, 2016
2 parents 48c47c7 + 01e0a9f commit 65b556a
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 75 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 2016-06-08 v2.2.0
* Fix bower dependency on jQuery to allow any supported version
* Allow developer to indicate that ajax calls should _not_ be retained (thanks @suchipi)
* Fix to allow responseTime to work with deferred jsonp
* Updated to test on latest jQuery versions
* Added JSDoc3 blocks to public API methods
* Refactored logging: now has levels, easier to overwrite, more messages
* Added ability for `data` matching to be a function (thanks @koorgoo)
* Added ability to pass in array of mocks in addition to singles (thanks again @koorgoo)

## 2016-02-07 v2.1.1
* Reorganize test cases into separate files for ease of maintenance and testing
* Fix #86: JSONP return data treated as JSON
Expand Down
20 changes: 10 additions & 10 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ module.exports = function(grunt) {
'1.9.1',
'1.10.2',
'1.11.3',
'1.12.3',
'1.12.4',
'2.0.3',
'2.1.4',
'2.2.3'
'2.2.4'
]
},
requirejs: {
Expand All @@ -78,24 +78,24 @@ module.exports = function(grunt) {
'1.9.1',
'1.10.2',
'1.11.3',
'1.12.3',
'1.12.4',
'2.0.3',
'2.1.4',
'2.2.3'
'2.2.4'
]
},
latestInBranch: {
jQueryVersions: [
'1.12.3',
'2.2.3'
'1.12.4',
'2.2.4'
]
},
oldestAndLatest: {
jQueryVersions: [
'1.5.2',
'1.12.3',
'1.12.4',
'2.1.4',
'2.2.3'
'2.2.4'
]
},
edge: {
Expand All @@ -111,10 +111,10 @@ module.exports = function(grunt) {
'1.9.1',
'1.10.2',
'1.11.3',
'1.12.3',
'1.12.4',
'2.0.3',
'2.1.4',
'2.2.3'
'2.2.4'
]
}
},
Expand Down
14 changes: 13 additions & 1 deletion dist/jquery.mockjax.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*! jQuery Mockjax
* A Plugin providing simple and flexible mocking of ajax requests and responses
*
* Version: 2.1.1
* Version: 2.2.0
* Home: https://github.com/jakerella/jquery-mockjax
* Copyright (c) 2016 Jordan Kasper, formerly appendTo;
* NOTE: This repository was taken over by Jordan Kasper (@jakerella) October, 2014
Expand Down Expand Up @@ -78,6 +78,11 @@
function isMockDataEqual( mock, live ) {
logger.debug( mock, ['Checking mock data against request data', mock, live] );
var identical = true;

if ( $.isFunction(mock) ) {
return !!mock(live);
}

// Test for situations where the data is a querystring (not an object)
if (typeof live === 'string') {
// Querystring may be a regex
Expand Down Expand Up @@ -890,6 +895,13 @@
* @return {Number} The id (index) of the mock handler suitable for clearing (see $.mockjax.clear())
*/
$.mockjax = function(settings) {
// Multiple mocks.
if ( $.isArray(settings) ) {
return $.map(settings, function(s) {
return $.mockjax(s);
});
}

var i = mockHandlers.length;
mockHandlers[i] = settings;
logger.log( settings, ['Created new mock handler', settings] );
Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.mockjax.min.js

Large diffs are not rendered by default.

25 changes: 9 additions & 16 deletions lib/jquery-1.12.3.js → lib/jquery-1.12.4.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* jQuery JavaScript Library v1.12.3
* jQuery JavaScript Library v1.12.4
* http://jquery.com/
*
* Includes Sizzle.js
Expand All @@ -9,7 +9,7 @@
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2016-04-05T19:16Z
* Date: 2016-05-20T17:17Z
*/

(function( global, factory ) {
Expand Down Expand Up @@ -65,7 +65,7 @@ var support = {};


var
version = "1.12.3",
version = "1.12.4",

// Define a local copy of jQuery
jQuery = function( selector, context ) {
Expand Down Expand Up @@ -6672,6 +6672,7 @@ var documentElement = document.documentElement;
if ( reliableHiddenOffsetsVal ) {
div.style.display = "";
div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
div.childNodes[ 0 ].style.borderCollapse = "separate";
contents = div.getElementsByTagName( "td" );
contents[ 0 ].style.cssText = "margin:0;border:0;padding:0;display:none";
reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
Expand Down Expand Up @@ -6996,19 +6997,6 @@ function getWidthOrHeight( elem, name, extra ) {
isBorderBox = support.boxSizing &&
jQuery.css( elem, "boxSizing", false, styles ) === "border-box";

// Support: IE11 only
// In IE 11 fullscreen elements inside of an iframe have
// 100x too small dimensions (gh-1764).
if ( document.msFullscreenElement && window.top !== window ) {

// Support: IE11 only
// Running getBoundingClientRect on a disconnected node
// in IE throws an error.
if ( elem.getClientRects().length ) {
val = Math.round( elem.getBoundingClientRect()[ name ] * 100 );
}
}

// some non-html elements return undefined for offsetWidth, so check for null/undefined
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
Expand Down Expand Up @@ -9999,6 +9987,11 @@ function getDisplay( elem ) {
}

function filterHidden( elem ) {

// Disconnected elements are considered hidden
if ( !jQuery.contains( elem.ownerDocument || document, elem ) ) {
return true;
}
while ( elem && elem.nodeType === 1 ) {
if ( getDisplay( elem ) === "none" || elem.type === "hidden" ) {
return true;
Expand Down
44 changes: 8 additions & 36 deletions lib/jquery-2.2.3.js → lib/jquery-2.2.4.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* jQuery JavaScript Library v2.2.3
* jQuery JavaScript Library v2.2.4
* http://jquery.com/
*
* Includes Sizzle.js
Expand All @@ -9,7 +9,7 @@
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2016-04-05T19:26Z
* Date: 2016-05-20T17:23Z
*/

(function( global, factory ) {
Expand Down Expand Up @@ -65,7 +65,7 @@ var support = {};


var
version = "2.2.3",
version = "2.2.4",

// Define a local copy of jQuery
jQuery = function( selector, context ) {
Expand Down Expand Up @@ -5006,13 +5006,14 @@ jQuery.Event.prototype = {
isDefaultPrevented: returnFalse,
isPropagationStopped: returnFalse,
isImmediatePropagationStopped: returnFalse,
isSimulated: false,

preventDefault: function() {
var e = this.originalEvent;

this.isDefaultPrevented = returnTrue;

if ( e ) {
if ( e && !this.isSimulated ) {
e.preventDefault();
}
},
Expand All @@ -5021,7 +5022,7 @@ jQuery.Event.prototype = {

this.isPropagationStopped = returnTrue;

if ( e ) {
if ( e && !this.isSimulated ) {
e.stopPropagation();
}
},
Expand All @@ -5030,7 +5031,7 @@ jQuery.Event.prototype = {

this.isImmediatePropagationStopped = returnTrue;

if ( e ) {
if ( e && !this.isSimulated ) {
e.stopImmediatePropagation();
}

Expand Down Expand Up @@ -5961,19 +5962,6 @@ function getWidthOrHeight( elem, name, extra ) {
styles = getStyles( elem ),
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";

// Support: IE11 only
// In IE 11 fullscreen elements inside of an iframe have
// 100x too small dimensions (gh-1764).
if ( document.msFullscreenElement && window.top !== window ) {

// Support: IE11 only
// Running getBoundingClientRect on a disconnected node
// in IE throws an error.
if ( elem.getClientRects().length ) {
val = Math.round( elem.getBoundingClientRect()[ name ] * 100 );
}
}

// Some non-html elements return undefined for offsetWidth, so check for null/undefined
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
Expand Down Expand Up @@ -7864,34 +7852,18 @@ jQuery.extend( jQuery.event, {
},

// Piggyback on a donor event to simulate a different one
// Used only for `focus(in | out)` events
simulate: function( type, elem, event ) {
var e = jQuery.extend(
new jQuery.Event(),
event,
{
type: type,
isSimulated: true

// Previously, `originalEvent: {}` was set here, so stopPropagation call
// would not be triggered on donor event, since in our own
// jQuery.event.stopPropagation function we had a check for existence of
// originalEvent.stopPropagation method, so, consequently it would be a noop.
//
// But now, this "simulate" function is used only for events
// for which stopPropagation() is noop, so there is no need for that anymore.
//
// For the 1.x branch though, guard for "click" and "submit"
// events is still used, but was moved to jQuery.event.stopPropagation function
// because `originalEvent` should point to the original event for the constancy
// with other events and for more focused logic
}
);

jQuery.event.trigger( e, null, elem );

if ( e.isDefaultPrevented() ) {
event.preventDefault();
}
}

} );
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "jquery-mockjax",
"title": "jQuery Mockjax",
"version": "2.1.1",
"version": "2.2.0",
"main": "./src/jquery.mockjax.js",
"description": "The jQuery Mockjax Plugin provides a simple and extremely flexible interface for mocking or simulating ajax requests and responses.",
"url": "https://github.com/jakerella/jquery-mockjax",
Expand Down
4 changes: 2 additions & 2 deletions test/dist-min.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ <h1 id='qunit-header'>
<a href='?jquery=1.9.1'>jQuery 1.9.1</a>
<a href='?jquery=1.10.2'>jQuery 1.10.2</a>
<a href='?jquery=1.11.3'>jQuery 1.11.3</a>
<a href='?jquery=1.12.3'>jQuery 1.12.3</a>
<a href='?jquery=1.12.4'>jQuery 1.12.4</a>
<a href='?jquery=2.0.3'>jQuery 2.0.3</a>
<a href='?jquery=2.1.4'>jQuery 2.1.4</a>
<a href='?jquery=2.2.3'>jQuery 2.2.3</a>
<a href='?jquery=2.2.4'>jQuery 2.2.4</a>
<a href='?jquery=git'>jQuery Latest (git)</a>
<button class='runall' disabled='disabled'>Run All Versions</button>
</h1>
Expand Down
4 changes: 2 additions & 2 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ <h1 id='qunit-header'>
<a href='?jquery=1.9.1'>jQuery 1.9.1</a>
<a href='?jquery=1.10.2'>jQuery 1.10.2</a>
<a href='?jquery=1.11.3'>jQuery 1.11.3</a>
<a href='?jquery=1.12.3'>jQuery 1.12.3</a>
<a href='?jquery=1.12.4'>jQuery 1.12.4</a>
<a href='?jquery=2.0.3'>jQuery 2.0.3</a>
<a href='?jquery=2.1.4'>jQuery 2.1.4</a>
<a href='?jquery=2.2.3'>jQuery 2.2.3</a>
<a href='?jquery=2.2.4'>jQuery 2.2.4</a>
<a href='?jquery=git'>jQuery Latest (git)</a>
<button class='runall' disabled='disabled'>Run All Versions</button>
</h1>
Expand Down
1 change: 1 addition & 0 deletions test/test-bugs.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@
complete: function(xhr) {
assert.ok(callbackExecuted, 'The jsonp callback was executed');
assert.equal(xhr.statusText, 'success', 'Response was successful');
window.abcdef123456 = null;
done();
}
});
Expand Down
15 changes: 12 additions & 3 deletions test/test-connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
url: '/delay',
complete: function() {
var delay = ((new Date()) - ts);
assert.ok( delay >= 150, 'Correct delay simulation (' + delay + ')' );
// check against 140ms to allow for browser variance
assert.ok( delay >= 140, 'Correct delay simulation (' + delay + ')' );
assert.strictEqual( executed, 1, 'Callback execution order correct');
done();
}
Expand All @@ -102,13 +103,17 @@

var executed = false, ts = new Date();

window.abcdef123456 = function() {};

$.ajax({
url: 'http://foobar.com/jsonp-delay?callback=?',
dataType: 'jsonp',
complete: function() {
var delay = ((new Date()) - ts);
assert.ok( delay >= 150, 'Correct delay simulation (' + delay + ')' );
// check against 140ms to allow for browser variance
assert.ok( delay >= 140, 'Correct delay simulation (' + delay + ')' );
assert.ok( executed, 'Callback execution order correct');
window.abcdef123456 = null;
done();
}
});
Expand All @@ -123,13 +128,17 @@
var done = assert.async();
var executed = false, ts = new Date();

window.abcdef123456 = function() {};

$.ajax({
url: 'http://foobar.com/jsonp-delay?callback=?',
dataType: 'jsonp'
}).done(function() {
var delay = ((new Date()) - ts);
assert.ok( delay >= 150, 'Correct delay simulation (' + delay + ')' );
// check against 140ms to allow for browser variance
assert.ok( delay >= 140, 'Correct delay simulation (' + delay + ')' );
assert.ok( executed, 'Callback execution order correct');
window.abcdef123456 = null;
done();
});

Expand Down
Loading

0 comments on commit 65b556a

Please sign in to comment.