Skip to content

Commit 65b556a

Browse files
authored
Merge pull request #294 from jakerella/v2.2.0
Upgrade library to v2.2.0
2 parents 48c47c7 + 01e0a9f commit 65b556a

15 files changed

+88
-75
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 2016-06-08 v2.2.0
2+
* Fix bower dependency on jQuery to allow any supported version
3+
* Allow developer to indicate that ajax calls should _not_ be retained (thanks @suchipi)
4+
* Fix to allow responseTime to work with deferred jsonp
5+
* Updated to test on latest jQuery versions
6+
* Added JSDoc3 blocks to public API methods
7+
* Refactored logging: now has levels, easier to overwrite, more messages
8+
* Added ability for `data` matching to be a function (thanks @koorgoo)
9+
* Added ability to pass in array of mocks in addition to singles (thanks again @koorgoo)
10+
111
## 2016-02-07 v2.1.1
212
* Reorganize test cases into separate files for ease of maintenance and testing
313
* Fix #86: JSONP return data treated as JSON

Gruntfile.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ module.exports = function(grunt) {
6565
'1.9.1',
6666
'1.10.2',
6767
'1.11.3',
68-
'1.12.3',
68+
'1.12.4',
6969
'2.0.3',
7070
'2.1.4',
71-
'2.2.3'
71+
'2.2.4'
7272
]
7373
},
7474
requirejs: {
@@ -78,24 +78,24 @@ module.exports = function(grunt) {
7878
'1.9.1',
7979
'1.10.2',
8080
'1.11.3',
81-
'1.12.3',
81+
'1.12.4',
8282
'2.0.3',
8383
'2.1.4',
84-
'2.2.3'
84+
'2.2.4'
8585
]
8686
},
8787
latestInBranch: {
8888
jQueryVersions: [
89-
'1.12.3',
90-
'2.2.3'
89+
'1.12.4',
90+
'2.2.4'
9191
]
9292
},
9393
oldestAndLatest: {
9494
jQueryVersions: [
9595
'1.5.2',
96-
'1.12.3',
96+
'1.12.4',
9797
'2.1.4',
98-
'2.2.3'
98+
'2.2.4'
9999
]
100100
},
101101
edge: {
@@ -111,10 +111,10 @@ module.exports = function(grunt) {
111111
'1.9.1',
112112
'1.10.2',
113113
'1.11.3',
114-
'1.12.3',
114+
'1.12.4',
115115
'2.0.3',
116116
'2.1.4',
117-
'2.2.3'
117+
'2.2.4'
118118
]
119119
}
120120
},

dist/jquery.mockjax.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*! jQuery Mockjax
22
* A Plugin providing simple and flexible mocking of ajax requests and responses
33
*
4-
* Version: 2.1.1
4+
* Version: 2.2.0
55
* Home: https://github.com/jakerella/jquery-mockjax
66
* Copyright (c) 2016 Jordan Kasper, formerly appendTo;
77
* NOTE: This repository was taken over by Jordan Kasper (@jakerella) October, 2014
@@ -78,6 +78,11 @@
7878
function isMockDataEqual( mock, live ) {
7979
logger.debug( mock, ['Checking mock data against request data', mock, live] );
8080
var identical = true;
81+
82+
if ( $.isFunction(mock) ) {
83+
return !!mock(live);
84+
}
85+
8186
// Test for situations where the data is a querystring (not an object)
8287
if (typeof live === 'string') {
8388
// Querystring may be a regex
@@ -890,6 +895,13 @@
890895
* @return {Number} The id (index) of the mock handler suitable for clearing (see $.mockjax.clear())
891896
*/
892897
$.mockjax = function(settings) {
898+
// Multiple mocks.
899+
if ( $.isArray(settings) ) {
900+
return $.map(settings, function(s) {
901+
return $.mockjax(s);
902+
});
903+
}
904+
893905
var i = mockHandlers.length;
894906
mockHandlers[i] = settings;
895907
logger.log( settings, ['Created new mock handler', settings] );

dist/jquery.mockjax.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/jquery-1.12.3.js renamed to lib/jquery-1.12.4.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jQuery JavaScript Library v1.12.3
2+
* jQuery JavaScript Library v1.12.4
33
* http://jquery.com/
44
*
55
* Includes Sizzle.js
@@ -9,7 +9,7 @@
99
* Released under the MIT license
1010
* http://jquery.org/license
1111
*
12-
* Date: 2016-04-05T19:16Z
12+
* Date: 2016-05-20T17:17Z
1313
*/
1414

1515
(function( global, factory ) {
@@ -65,7 +65,7 @@ var support = {};
6565

6666

6767
var
68-
version = "1.12.3",
68+
version = "1.12.4",
6969

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

6999-
// Support: IE11 only
7000-
// In IE 11 fullscreen elements inside of an iframe have
7001-
// 100x too small dimensions (gh-1764).
7002-
if ( document.msFullscreenElement && window.top !== window ) {
7003-
7004-
// Support: IE11 only
7005-
// Running getBoundingClientRect on a disconnected node
7006-
// in IE throws an error.
7007-
if ( elem.getClientRects().length ) {
7008-
val = Math.round( elem.getBoundingClientRect()[ name ] * 100 );
7009-
}
7010-
}
7011-
70127000
// some non-html elements return undefined for offsetWidth, so check for null/undefined
70137001
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
70147002
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
@@ -9999,6 +9987,11 @@ function getDisplay( elem ) {
99999987
}
100009988

100019989
function filterHidden( elem ) {
9990+
9991+
// Disconnected elements are considered hidden
9992+
if ( !jQuery.contains( elem.ownerDocument || document, elem ) ) {
9993+
return true;
9994+
}
100029995
while ( elem && elem.nodeType === 1 ) {
100039996
if ( getDisplay( elem ) === "none" || elem.type === "hidden" ) {
100049997
return true;

lib/jquery-2.2.3.js renamed to lib/jquery-2.2.4.js

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jQuery JavaScript Library v2.2.3
2+
* jQuery JavaScript Library v2.2.4
33
* http://jquery.com/
44
*
55
* Includes Sizzle.js
@@ -9,7 +9,7 @@
99
* Released under the MIT license
1010
* http://jquery.org/license
1111
*
12-
* Date: 2016-04-05T19:26Z
12+
* Date: 2016-05-20T17:23Z
1313
*/
1414

1515
(function( global, factory ) {
@@ -65,7 +65,7 @@ var support = {};
6565

6666

6767
var
68-
version = "2.2.3",
68+
version = "2.2.4",
6969

7070
// Define a local copy of jQuery
7171
jQuery = function( selector, context ) {
@@ -5006,13 +5006,14 @@ jQuery.Event.prototype = {
50065006
isDefaultPrevented: returnFalse,
50075007
isPropagationStopped: returnFalse,
50085008
isImmediatePropagationStopped: returnFalse,
5009+
isSimulated: false,
50095010

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

50135014
this.isDefaultPrevented = returnTrue;
50145015

5015-
if ( e ) {
5016+
if ( e && !this.isSimulated ) {
50165017
e.preventDefault();
50175018
}
50185019
},
@@ -5021,7 +5022,7 @@ jQuery.Event.prototype = {
50215022

50225023
this.isPropagationStopped = returnTrue;
50235024

5024-
if ( e ) {
5025+
if ( e && !this.isSimulated ) {
50255026
e.stopPropagation();
50265027
}
50275028
},
@@ -5030,7 +5031,7 @@ jQuery.Event.prototype = {
50305031

50315032
this.isImmediatePropagationStopped = returnTrue;
50325033

5033-
if ( e ) {
5034+
if ( e && !this.isSimulated ) {
50345035
e.stopImmediatePropagation();
50355036
}
50365037

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

5964-
// Support: IE11 only
5965-
// In IE 11 fullscreen elements inside of an iframe have
5966-
// 100x too small dimensions (gh-1764).
5967-
if ( document.msFullscreenElement && window.top !== window ) {
5968-
5969-
// Support: IE11 only
5970-
// Running getBoundingClientRect on a disconnected node
5971-
// in IE throws an error.
5972-
if ( elem.getClientRects().length ) {
5973-
val = Math.round( elem.getBoundingClientRect()[ name ] * 100 );
5974-
}
5975-
}
5976-
59775965
// Some non-html elements return undefined for offsetWidth, so check for null/undefined
59785966
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
59795967
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
@@ -7864,34 +7852,18 @@ jQuery.extend( jQuery.event, {
78647852
},
78657853

78667854
// Piggyback on a donor event to simulate a different one
7855+
// Used only for `focus(in | out)` events
78677856
simulate: function( type, elem, event ) {
78687857
var e = jQuery.extend(
78697858
new jQuery.Event(),
78707859
event,
78717860
{
78727861
type: type,
78737862
isSimulated: true
7874-
7875-
// Previously, `originalEvent: {}` was set here, so stopPropagation call
7876-
// would not be triggered on donor event, since in our own
7877-
// jQuery.event.stopPropagation function we had a check for existence of
7878-
// originalEvent.stopPropagation method, so, consequently it would be a noop.
7879-
//
7880-
// But now, this "simulate" function is used only for events
7881-
// for which stopPropagation() is noop, so there is no need for that anymore.
7882-
//
7883-
// For the 1.x branch though, guard for "click" and "submit"
7884-
// events is still used, but was moved to jQuery.event.stopPropagation function
7885-
// because `originalEvent` should point to the original event for the constancy
7886-
// with other events and for more focused logic
78877863
}
78887864
);
78897865

78907866
jQuery.event.trigger( e, null, elem );
7891-
7892-
if ( e.isDefaultPrevented() ) {
7893-
event.preventDefault();
7894-
}
78957867
}
78967868

78977869
} );

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jquery-mockjax",
33
"title": "jQuery Mockjax",
4-
"version": "2.1.1",
4+
"version": "2.2.0",
55
"main": "./src/jquery.mockjax.js",
66
"description": "The jQuery Mockjax Plugin provides a simple and extremely flexible interface for mocking or simulating ajax requests and responses.",
77
"url": "https://github.com/jakerella/jquery-mockjax",

test/dist-min.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ <h1 id='qunit-header'>
3636
<a href='?jquery=1.9.1'>jQuery 1.9.1</a>
3737
<a href='?jquery=1.10.2'>jQuery 1.10.2</a>
3838
<a href='?jquery=1.11.3'>jQuery 1.11.3</a>
39-
<a href='?jquery=1.12.3'>jQuery 1.12.3</a>
39+
<a href='?jquery=1.12.4'>jQuery 1.12.4</a>
4040
<a href='?jquery=2.0.3'>jQuery 2.0.3</a>
4141
<a href='?jquery=2.1.4'>jQuery 2.1.4</a>
42-
<a href='?jquery=2.2.3'>jQuery 2.2.3</a>
42+
<a href='?jquery=2.2.4'>jQuery 2.2.4</a>
4343
<a href='?jquery=git'>jQuery Latest (git)</a>
4444
<button class='runall' disabled='disabled'>Run All Versions</button>
4545
</h1>

test/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ <h1 id='qunit-header'>
3636
<a href='?jquery=1.9.1'>jQuery 1.9.1</a>
3737
<a href='?jquery=1.10.2'>jQuery 1.10.2</a>
3838
<a href='?jquery=1.11.3'>jQuery 1.11.3</a>
39-
<a href='?jquery=1.12.3'>jQuery 1.12.3</a>
39+
<a href='?jquery=1.12.4'>jQuery 1.12.4</a>
4040
<a href='?jquery=2.0.3'>jQuery 2.0.3</a>
4141
<a href='?jquery=2.1.4'>jQuery 2.1.4</a>
42-
<a href='?jquery=2.2.3'>jQuery 2.2.3</a>
42+
<a href='?jquery=2.2.4'>jQuery 2.2.4</a>
4343
<a href='?jquery=git'>jQuery Latest (git)</a>
4444
<button class='runall' disabled='disabled'>Run All Versions</button>
4545
</h1>

test/test-bugs.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@
245245
complete: function(xhr) {
246246
assert.ok(callbackExecuted, 'The jsonp callback was executed');
247247
assert.equal(xhr.statusText, 'success', 'Response was successful');
248+
window.abcdef123456 = null;
248249
done();
249250
}
250251
});

test/test-connection.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@
8686
url: '/delay',
8787
complete: function() {
8888
var delay = ((new Date()) - ts);
89-
assert.ok( delay >= 150, 'Correct delay simulation (' + delay + ')' );
89+
// check against 140ms to allow for browser variance
90+
assert.ok( delay >= 140, 'Correct delay simulation (' + delay + ')' );
9091
assert.strictEqual( executed, 1, 'Callback execution order correct');
9192
done();
9293
}
@@ -102,13 +103,17 @@
102103

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

106+
window.abcdef123456 = function() {};
107+
105108
$.ajax({
106109
url: 'http://foobar.com/jsonp-delay?callback=?',
107110
dataType: 'jsonp',
108111
complete: function() {
109112
var delay = ((new Date()) - ts);
110-
assert.ok( delay >= 150, 'Correct delay simulation (' + delay + ')' );
113+
// check against 140ms to allow for browser variance
114+
assert.ok( delay >= 140, 'Correct delay simulation (' + delay + ')' );
111115
assert.ok( executed, 'Callback execution order correct');
116+
window.abcdef123456 = null;
112117
done();
113118
}
114119
});
@@ -123,13 +128,17 @@
123128
var done = assert.async();
124129
var executed = false, ts = new Date();
125130

131+
window.abcdef123456 = function() {};
132+
126133
$.ajax({
127134
url: 'http://foobar.com/jsonp-delay?callback=?',
128135
dataType: 'jsonp'
129136
}).done(function() {
130137
var delay = ((new Date()) - ts);
131-
assert.ok( delay >= 150, 'Correct delay simulation (' + delay + ')' );
138+
// check against 140ms to allow for browser variance
139+
assert.ok( delay >= 140, 'Correct delay simulation (' + delay + ')' );
132140
assert.ok( executed, 'Callback execution order correct');
141+
window.abcdef123456 = null;
133142
done();
134143
});
135144

0 commit comments

Comments
 (0)