mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-27 15:54:23 +02:00
Replaced mockjax with axios-mock-request
This commit is contained in:
parent
4fe9676318
commit
a58c36c9b4
@ -16,6 +16,7 @@
|
|||||||
"test": "export NODE_PATH=src && mocha src/lib-test/preprocessor.js --compilers js:babel-core/register --recursive src/**/**/__tests__/*-test.js"
|
"test": "export NODE_PATH=src && mocha src/lib-test/preprocessor.js --compilers js:babel-core/register --recursive src/**/**/__tests__/*-test.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"axios-mock-adapter": "^1.15.0",
|
||||||
"babel-core": "^5.8.22",
|
"babel-core": "^5.8.22",
|
||||||
"babel-plugin-transform-class-properties": "^6.11.5",
|
"babel-plugin-transform-class-properties": "^6.11.5",
|
||||||
"babel-register": "^6.7.2",
|
"babel-register": "^6.7.2",
|
||||||
@ -42,7 +43,6 @@
|
|||||||
"gulp-uglify": "^2.1.2",
|
"gulp-uglify": "^2.1.2",
|
||||||
"gulp-util": "^3.0.6",
|
"gulp-util": "^3.0.6",
|
||||||
"humps": "^0.6.0",
|
"humps": "^0.6.0",
|
||||||
"jquery-mockjax": "^2.1.0",
|
|
||||||
"jsdom": "^8.4.1",
|
"jsdom": "^8.4.1",
|
||||||
"morgan": "^1.6.1",
|
"morgan": "^1.6.1",
|
||||||
"proxyquire": "^1.7.4",
|
"proxyquire": "^1.7.4",
|
||||||
@ -61,7 +61,6 @@
|
|||||||
"draft-js": "^0.10.0",
|
"draft-js": "^0.10.0",
|
||||||
"draft-js-export-html": "^0.5.2",
|
"draft-js-export-html": "^0.5.2",
|
||||||
"history": "^3.0.0",
|
"history": "^3.0.0",
|
||||||
"jquery": "^2.1.4",
|
|
||||||
"keycode": "^2.1.4",
|
"keycode": "^2.1.4",
|
||||||
"localStorage": "^1.0.3",
|
"localStorage": "^1.0.3",
|
||||||
"lodash": "^3.10.0",
|
"lodash": "^3.10.0",
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const $ = require('jquery');
|
const axios = require('axios');
|
||||||
const mockjax = require('jquery-mockjax')($, window);
|
const MockAdapter = require('axios-mock-adapter');
|
||||||
|
const qs = require('qs');
|
||||||
|
const mock = new MockAdapter(axios);
|
||||||
|
|
||||||
let fixtures = (function () {
|
let fixtures = (function () {
|
||||||
let fixturesData = [];
|
let fixturesData = [];
|
||||||
@ -23,12 +25,9 @@ fixtures.add(require('data/fixtures/system-fixtures'));
|
|||||||
fixtures.add(require('data/fixtures/article-fixtures'));
|
fixtures.add(require('data/fixtures/article-fixtures'));
|
||||||
|
|
||||||
_.each(fixtures.getAll(), function (fixture) {
|
_.each(fixtures.getAll(), function (fixture) {
|
||||||
mockjax({
|
mock.onAny('http://localhost:3000/api' + fixture.path).reply(function(config) {
|
||||||
contentType: fixture.contentType || 'application/json',
|
return new Promise(function(resolve, reject) {
|
||||||
url: 'http://localhost:3000/api' + fixture.path,
|
setTimeout(() => resolve([200, fixture.response(qs.parse(config.data))]), fixture.time || 500);
|
||||||
responseTime: fixture.time || 500,
|
});
|
||||||
response: function (settings) {
|
|
||||||
this.responseText = fixture.response(settings.data);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -13,7 +13,7 @@ const APIUtils = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if(!dataAsForm){
|
if(!dataAsForm){
|
||||||
options.headers = {'content-type': 'application/x-www-form-urlencoded'},
|
options.headers = {'content-type': 'application/x-www-form-urlencoded'};
|
||||||
options.data = qs.stringify(options.data);
|
options.data = qs.stringify(options.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user