@availity/api-core
Advanced tools
Comparing version 1.0.0-alpha.9 to 1.0.0-alpha.10
{ | ||
"name": "@availity/api-core", | ||
"version": "1.0.0-alpha.9", | ||
"version": "1.0.0-alpha.10", | ||
"description": "Base API definitions for the Availity REST API", | ||
@@ -17,6 +17,6 @@ "keywords": [ | ||
"peerDependencies": { | ||
"@availity/localstorage-core": "^1.0.0-alpha.9" | ||
"@availity/localstorage-core": "^1.0.0-alpha.10" | ||
}, | ||
"devDependencies": { | ||
"@availity/localstorage-core": "^1.0.0-alpha.9" | ||
"@availity/localstorage-core": "^1.0.0-alpha.10" | ||
}, | ||
@@ -23,0 +23,0 @@ "publishConfig": { |
@@ -237,4 +237,4 @@ import AvLocalStorage from '@availity/localstorage-core'; | ||
put(id, data, config) { | ||
return this.update(id, data, config); | ||
put(...args) { | ||
return this.update(args); | ||
} | ||
@@ -244,5 +244,4 @@ | ||
remove(id, config) { | ||
let data; | ||
if (typeof id !== 'string' && typeof id !== 'number') { | ||
data = id; | ||
config = id; | ||
id = ''; | ||
@@ -253,7 +252,6 @@ } | ||
config.url = this.getUrl(config, id); | ||
config.data = data; | ||
const beforeFunc = this.beforeRemove || this.beforeDelete; | ||
if (beforeFunc) { | ||
config.data = beforeFunc(config.data); | ||
config = beforeFunc(config); | ||
} | ||
@@ -263,5 +261,5 @@ return this.request(config, this.afterRemove || this.afterDelete); | ||
delete(id, config) { | ||
return this.remove(id, config); | ||
delete(...args) { | ||
return this.remove(args); | ||
} | ||
} |
import AvApi from './api'; | ||
import AvLogMessages from './resources/logs'; | ||
import AvNavigation from './resources/navigation'; | ||
import AvNotification from './resources/notification'; | ||
import AvNotification from './resources/notifications'; | ||
import AvOrganizations from './resources/organizations'; | ||
@@ -6,0 +6,0 @@ import AvPermissions from './resources/permissions'; |
@@ -722,44 +722,32 @@ import AvApi from '../api'; | ||
test('remove() should set first argument as data if not string or number', () => { | ||
test('remove() should set first argument as config if not string or number', () => { | ||
const config = { | ||
testValue: 'test', | ||
method: 'DELETE', | ||
url: testUrl, | ||
data: { | ||
a: '1', | ||
b: '2', | ||
}, | ||
}; | ||
const data = { | ||
testData: 'data', | ||
}; | ||
const expectedConfig = Object.assign( | ||
{ | ||
method: 'DELETE', | ||
url: testUrl, | ||
}, | ||
config, | ||
{ data } | ||
); | ||
api.remove(data, config); | ||
expect(api.getUrl).toHaveBeenLastCalledWith(expectedConfig, ''); | ||
expect(api.request).toHaveBeenLastCalledWith(expectedConfig, undefined); | ||
api.remove(config); | ||
expect(api.getUrl).toHaveBeenLastCalledWith(config, ''); | ||
expect(api.request).toHaveBeenLastCalledWith(config, undefined); | ||
}); | ||
test('remove() should run data through beforeRemove if defined', () => { | ||
test('remove() should call beforeRemove() if defined', () => { | ||
const config = { | ||
testValue: 'test', | ||
method: 'DELETE', | ||
url: testUrl, | ||
data: { | ||
a: '1', | ||
b: '2', | ||
}, | ||
}; | ||
const data = { | ||
testData: 'data', | ||
}; | ||
const expectedConfig = Object.assign( | ||
{ | ||
method: 'DELETE', | ||
url: testUrl, | ||
}, | ||
config, | ||
{ data } | ||
); | ||
api.beforeRemove = jest.fn(thisData => thisData); | ||
api.remove(data, config); | ||
expect(api.getUrl).toHaveBeenLastCalledWith(expectedConfig, ''); | ||
expect(api.request).toHaveBeenLastCalledWith(expectedConfig, undefined); | ||
expect(api.beforeRemove).toHaveBeenLastCalledWith(data); | ||
api.remove(config); | ||
expect(api.getUrl).toHaveBeenLastCalledWith(config, ''); | ||
expect(api.request).toHaveBeenLastCalledWith(config, undefined); | ||
expect(api.beforeRemove).toHaveBeenLastCalledWith(config); | ||
}); | ||
}); | ||
}); |
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
56395
1586