Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mobx-rest-jquery-adapter

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobx-rest-jquery-adapter - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

CHANGELOG.md

55

__tests__/adapter.spec.js

@@ -238,7 +238,8 @@ import adapter from '../src'

describe('del', () => {
describe('patch', () => {
let ret
const data = { name: 'paco' }
const action = () => {
ret = adapter.del('/users')
ret = adapter.patch('/users', data)
}

@@ -261,2 +262,50 @@

expect(jq.ajax.mock.calls[0][1]).toEqual({
method: 'PATCH',
contentType: 'application/json',
headers: { 'SomeHeader': 'test' },
xhrFields: { withCredentials: true },
data: '{"name":"paco"}'
})
})
})
})
describe('when it fails', () => {
const values = '{"errors": ["foo"]}'
beforeEach(() => {
injectFail(values)
action()
})
it('sends a xhr request with data parameters', () => {
expect(ret.abort).toBeTruthy()
return ret.promise.catch((vals) => {
expect(vals).toEqual(['foo'])
})
})
})
})
describe('del', () => {
let ret
const action = () => { ret = adapter.del('/users', { foo: 'bar' }) }
describe('when it resolves', () => {
const values = { id: 1, name: 'paco' }
beforeEach(() => {
injectDone(values)
action()
})
it('sends a xhr request with data parameters', () => {
expect(ret.abort).toBeTruthy()
return ret.promise.then((vals) => {
expect(vals).toEqual(values)
expect(jq.ajax.mock.calls[0][0]).toBe('/api/users')
expect(jq.ajax.mock.calls[0][1]).toEqual({
method: 'DELETE',

@@ -266,3 +315,3 @@ contentType: 'application/json',

xhrFields: { withCredentials: true },
data: null
data: '{"foo":"bar"}'
})

@@ -269,0 +318,0 @@ })

11

lib/index.js

@@ -118,7 +118,12 @@ 'use strict';

},
del: function del(path) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
patch: function patch(path, data) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
return ajax('' + this.apiPath + path, (0, _lodash.merge)({}, { method: 'DELETE' }, this.commonOptions, options));
return ajax('' + this.apiPath + path, (0, _lodash.merge)({}, { method: 'PATCH', data: data }, this.commonOptions, options));
},
del: function del(path, data) {
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
return ajax('' + this.apiPath + path, (0, _lodash.merge)({}, { method: 'DELETE', data: data }, this.commonOptions, options));
}
};
{
"name": "mobx-rest-jquery-adapter",
"version": "1.0.3",
"version": "1.0.4",
"description": "jQuery adapter for mobx-rest",

@@ -27,19 +27,19 @@ "repository": {

"dependencies": {
"jquery": "^3.4.0",
"lodash": "^4.17.4"
"jquery": "3.4.0",
"lodash": "4.17.4"
},
"devDependencies": {
"babel-cli": "^6.10.1",
"babel-core": "^6.10.4",
"babel-eslint": "^7.1.1",
"babel-jest": "^18.0.0",
"babel-plugin-transform-flow-strip-types": "^6.8.0",
"babel-polyfill": "^6.9.1",
"babel-preset-es2015": "^6.3.13",
"babel-preset-stage-1": "^6.5.0",
"babel-register": "^6.9.0",
"flow-bin": "^0.38.0",
"jest": "^18.1.0",
"snazzy": "^6.0.0",
"standard": "^8.6.0"
"babel-cli": "6.10.1",
"babel-core": "6.10.4",
"babel-eslint": "7.1.1",
"babel-jest": "18.0.0",
"babel-plugin-transform-flow-strip-types": "6.8.0",
"babel-polyfill": "6.9.1",
"babel-preset-es2015": "6.3.13",
"babel-preset-stage-1": "6.5.0",
"babel-register": "6.9.0",
"flow-bin": "0.38.0",
"jest": "18.1.0",
"snazzy": "6.0.0",
"standard": "8.6.0"
},

@@ -46,0 +46,0 @@ "main": "lib",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc