Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 2018-06-17 v2.4.0
* Added support for an array of status codes in mocked response (thanks @reinrl)
* Updated broken Codacy badge
* Added jQuery 3.3.1 to test suite
* Switched to using Chrome headless (with puppeteer) for all tests
* No longer testing in Opera, and added Edge to the browser test list

## 2018-01-07 v2.3.0
* Added new `handlers()` method
* Add basic support for 301 and 302 status codes with auto-redirection
Expand Down
14 changes: 11 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

const testRunner = require('./qunit-puppeteer.js');
/* jshint ignore:start */
var testRunner = require('./qunit-puppeteer.js');
/* jshint ignore:end */

module.exports = function(grunt) {
'use strict';
Expand Down Expand Up @@ -172,7 +174,9 @@ module.exports = function(grunt) {
grunt.registerTask('build', ['dev', 'concat', 'uglify', 'test:dist']);
grunt.registerTask('default', ['dev']);

/* jshint ignore:start */
grunt.registerTask('test', 'Executes QUnit tests with all supported jQuery versions', async function() {
/* jshint ignore:end */
var done = this.async();

var i, l,
Expand Down Expand Up @@ -201,15 +205,19 @@ module.exports = function(grunt) {
}

console.log(versionUrls);
for (let i=0; i<versionUrls.length; ++i) {
console.log('LOADING', versionUrls[i]);
for (i=0; i<versionUrls.length; ++i) {
try {
console.log('LOADING', versionUrls[i]);
/* jshint ignore:start */
await testRunner(versionUrls[i], PORT);
/* jshint ignore:end */
} catch(err) {
return done(err);
}
}
done();
/* jshint ignore:start */
});
/* jshint ignore:end */

};
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,10 @@ We use virtual machines to test current versions of the browsers below. In addit
we test the specific versions of IE specified.

* Internet Explorer 8-11
* Edge
* Firefox
* Safari
* Chrome
* Opera

_Please note that while we strive to keep `master` as bug free as possible, we do
not necessarily run tests in all of the above browsers for every single commit. We
Expand Down
9 changes: 7 additions & 2 deletions 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.3.0
* Version: 2.4.0
* Home: https://github.com/jakerella/jquery-mockjax
* Copyright (c) 2018 Jordan Kasper, formerly appendTo;
* NOTE: This repository was taken over by Jordan Kasper (@jakerella) October, 2014
Expand Down Expand Up @@ -286,9 +286,14 @@
} else {
this.responseText = mockHandler.responseText;
}
if( typeof mockHandler.status === 'number' || typeof mockHandler.status === 'string' ) {

if ($.isArray(mockHandler.status)) {
var idxStatus = Math.floor(Math.random() * mockHandler.status.length);
this.status = mockHandler.status[idxStatus];
} else if (typeof mockHandler.status === 'number' || typeof mockHandler.status === 'string') {
this.status = mockHandler.status;
}

if( typeof mockHandler.statusText === 'string') {
this.statusText = mockHandler.statusText;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.mockjax.min.js

Large diffs are not rendered by default.

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.3.0",
"version": "2.4.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
8 changes: 4 additions & 4 deletions src/jquery.mockjax.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,14 @@
} else {
this.responseText = mockHandler.responseText;
}

if ($.isArray(mockHandler.status)) {
var idxStatus = Math.floor(Math.random() * mockHandler.status.length)
this.status = mockHandler.status[idxStatus];
var idxStatus = Math.floor(Math.random() * mockHandler.status.length);
this.status = mockHandler.status[idxStatus];
} else if (typeof mockHandler.status === 'number' || typeof mockHandler.status === 'string') {
this.status = mockHandler.status;
}

if( typeof mockHandler.statusText === 'string') {
this.statusText = mockHandler.statusText;
}
Expand Down