mobx-rest-jquery-adapter
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -185,2 +185,29 @@ import adapter from '../src' | ||
}) | ||
describe('when it contains an array of files', () => { | ||
const values = [{ id: 1, avatar: 'lol.png' }] | ||
beforeEach(() => { | ||
data = { files: [new File([''], 'filename')] } | ||
injectDone(values) | ||
action() | ||
}) | ||
it('sends a xhr request with data parameters', () => { | ||
expect(ret.abort).toBeTruthy() | ||
return ret.promise.then((vals) => { | ||
const res = jq.ajax.mock.calls[0][1] | ||
expect(vals).toEqual(values) | ||
expect(jq.ajax.mock.calls[0][0]).toBe('/api/users') | ||
expect(res.cache).toBe(false) | ||
expect(res.contentType).toBe(false) | ||
expect(res.data).toBeTruthy() | ||
expect(res.method).toBe('POST') | ||
expect(res.processData).toBe(false) | ||
expect(res.xhr).toBeTruthy() | ||
}) | ||
}) | ||
}) | ||
}) | ||
@@ -187,0 +214,0 @@ |
@@ -11,2 +11,4 @@ 'use strict'; | ||
var _utils = require('./utils'); | ||
var _lodash = require('lodash'); | ||
@@ -32,2 +34,3 @@ | ||
function ajaxOptions(options) { | ||
@@ -42,14 +45,8 @@ if (options.method === 'GET') { | ||
var formData = new FormData(); | ||
var hasFile = false; | ||
var _buildFormData = (0, _utils.buildFormData)(options.data), | ||
hasFile = _buildFormData.hasFile, | ||
formData = _buildFormData.formData; | ||
(0, _lodash.forEach)(options.data, function (val, attr) { | ||
hasFile = hasFile || val instanceof File; | ||
if (!(0, _lodash.isNull)(val)) formData.append(attr, val); | ||
}); | ||
var baseOptions = { method: options.method }; | ||
var baseOptions = { | ||
method: options.method | ||
}; | ||
if (hasFile) { | ||
@@ -56,0 +53,0 @@ return Object.assign({}, baseOptions, { |
{ | ||
"name": "mobx-rest-jquery-adapter", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "jQuery adapter for mobx-rest", | ||
@@ -28,3 +28,3 @@ "repository": { | ||
"jquery": "3.4.0", | ||
"lodash": "4.17.11" | ||
"lodash": "4.17.13" | ||
}, | ||
@@ -31,0 +31,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
381990
13
7424
0
+ Addedlodash@4.17.13(transitive)
- Removedlodash@4.17.11(transitive)
Updatedlodash@4.17.13