@lion/ajax
Advanced tools
Comparing version 0.4.4 to 0.5.0
208
CHANGELOG.md
# Change Log | ||
## 0.5.0 | ||
### Minor Changes | ||
- 9ecab4d5: Removing LionSingleton as es modules are already guaranteed to be singletons. | ||
This reduces complexity and means less code to ship to our users. | ||
### Patch Changes | ||
- Updated dependencies [3c61fd29] | ||
- Updated dependencies [09d96759] | ||
- Updated dependencies [9ecab4d5] | ||
- @lion/core@0.9.0 | ||
- singleton-manager@1.1.2 | ||
All notable changes to this project will be documented in this file. | ||
@@ -10,6 +25,2 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
## [0.4.3](https://github.com/ing-bank/lion/compare/@lion/ajax@0.4.2...@lion/ajax@0.4.3) (2020-06-18) | ||
@@ -19,6 +30,2 @@ | ||
## [0.4.2](https://github.com/ing-bank/lion/compare/@lion/ajax@0.4.1...@lion/ajax@0.4.2) (2020-06-08) | ||
@@ -28,39 +35,20 @@ | ||
## [0.4.1](https://github.com/ing-bank/lion/compare/@lion/ajax@0.4.0...@lion/ajax@0.4.1) (2020-06-03) | ||
### Bug Fixes | ||
* remove all stories folders from npm ([1e04d06](https://github.com/ing-bank/lion/commit/1e04d06921f9d5e1a446b6d14045154ff83771c3)) | ||
- remove all stories folders from npm ([1e04d06](https://github.com/ing-bank/lion/commit/1e04d06921f9d5e1a446b6d14045154ff83771c3)) | ||
# [0.4.0](https://github.com/ing-bank/lion/compare/@lion/ajax@0.3.0...@lion/ajax@0.4.0) (2020-05-29) | ||
### Features | ||
* use markdown javascript (mdjs) for documentation ([bcd074d](https://github.com/ing-bank/lion/commit/bcd074d1fbce8754d428538df723ba402603e2c8)) | ||
- use markdown javascript (mdjs) for documentation ([bcd074d](https://github.com/ing-bank/lion/commit/bcd074d1fbce8754d428538df723ba402603e2c8)) | ||
# [0.3.0](https://github.com/ing-bank/lion/compare/@lion/ajax@0.2.10...@lion/ajax@0.3.0) (2020-05-18) | ||
### Features | ||
* use singleton manager to support nested npm installations ([e2eb0e0](https://github.com/ing-bank/lion/commit/e2eb0e0077b9efed9382701461753778f63cad48)) | ||
- use singleton manager to support nested npm installations ([e2eb0e0](https://github.com/ing-bank/lion/commit/e2eb0e0077b9efed9382701461753778f63cad48)) | ||
## [0.2.10](https://github.com/ing-bank/lion/compare/@lion/ajax@0.2.9...@lion/ajax@0.2.10) (2020-04-29) | ||
@@ -70,6 +58,2 @@ | ||
## [0.2.9](https://github.com/ing-bank/lion/compare/@lion/ajax@0.2.8...@lion/ajax@0.2.9) (2020-04-02) | ||
@@ -79,6 +63,2 @@ | ||
## [0.2.8](https://github.com/ing-bank/lion/compare/@lion/ajax@0.2.7...@lion/ajax@0.2.8) (2020-03-25) | ||
@@ -88,6 +68,2 @@ | ||
## [0.2.7](https://github.com/ing-bank/lion/compare/@lion/ajax@0.2.6...@lion/ajax@0.2.7) (2020-03-05) | ||
@@ -97,6 +73,2 @@ | ||
## [0.2.6](https://github.com/ing-bank/lion/compare/@lion/ajax@0.2.5...@lion/ajax@0.2.6) (2020-02-26) | ||
@@ -106,17 +78,8 @@ | ||
## [0.2.5](https://github.com/ing-bank/lion/compare/@lion/ajax@0.2.4...@lion/ajax@0.2.5) (2020-02-19) | ||
### Bug Fixes | ||
* reduce storybook chunck sizes for more performance ([9fc5606](https://github.com/ing-bank/lion/commit/9fc560605f5dcf6e9abcf8d58079c59f12750046)) | ||
- reduce storybook chunck sizes for more performance ([9fc5606](https://github.com/ing-bank/lion/commit/9fc560605f5dcf6e9abcf8d58079c59f12750046)) | ||
## [0.2.4](https://github.com/ing-bank/lion/compare/@lion/ajax@0.2.3...@lion/ajax@0.2.4) (2020-02-06) | ||
@@ -126,17 +89,8 @@ | ||
## [0.2.3](https://github.com/ing-bank/lion/compare/@lion/ajax@0.2.2...@lion/ajax@0.2.3) (2020-01-29) | ||
### Bug Fixes | ||
* update broken ajax storybook link ([f731ade](https://github.com/ing-bank/lion/commit/f731ade8f02f68cc140228bfd1d58934c403a57d)) | ||
- update broken ajax storybook link ([f731ade](https://github.com/ing-bank/lion/commit/f731ade8f02f68cc140228bfd1d58934c403a57d)) | ||
## [0.2.2](https://github.com/ing-bank/lion/compare/@lion/ajax@0.2.1...@lion/ajax@0.2.2) (2020-01-20) | ||
@@ -146,39 +100,20 @@ | ||
## [0.2.1](https://github.com/ing-bank/lion/compare/@lion/ajax@0.2.0...@lion/ajax@0.2.1) (2020-01-17) | ||
### Bug Fixes | ||
* update storybook and use main.js ([e61e0b9](https://github.com/ing-bank/lion/commit/e61e0b938ff72cc18cc0b3aa1560f2cece0c9fe6)) | ||
- update storybook and use main.js ([e61e0b9](https://github.com/ing-bank/lion/commit/e61e0b938ff72cc18cc0b3aa1560f2cece0c9fe6)) | ||
# [0.2.0](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.20...@lion/ajax@0.2.0) (2020-01-13) | ||
### Features | ||
* improved storybook demos ([89b835a](https://github.com/ing-bank/lion/commit/89b835a79998c45a28093de01f69216c35009a40)) | ||
- improved storybook demos ([89b835a](https://github.com/ing-bank/lion/commit/89b835a79998c45a28093de01f69216c35009a40)) | ||
## [0.1.20](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.19...@lion/ajax@0.1.20) (2019-12-02) | ||
### Bug Fixes | ||
* use strict versions to get correct deps on older versions ([8645c13](https://github.com/ing-bank/lion/commit/8645c13b1d77e488713f2e5e0e4e00c4d30ea1ee)) | ||
- use strict versions to get correct deps on older versions ([8645c13](https://github.com/ing-bank/lion/commit/8645c13b1d77e488713f2e5e0e4e00c4d30ea1ee)) | ||
## [0.1.19](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.18...@lion/ajax@0.1.19) (2019-11-13) | ||
@@ -188,6 +123,2 @@ | ||
## [0.1.18](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.17...@lion/ajax@0.1.18) (2019-10-23) | ||
@@ -197,6 +128,2 @@ | ||
## [0.1.17](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.16...@lion/ajax@0.1.17) (2019-09-25) | ||
@@ -206,6 +133,2 @@ | ||
## [0.1.16](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.15...@lion/ajax@0.1.16) (2019-07-25) | ||
@@ -215,6 +138,2 @@ | ||
## [0.1.15](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.14...@lion/ajax@0.1.15) (2019-07-24) | ||
@@ -224,6 +143,2 @@ | ||
## [0.1.14](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.13...@lion/ajax@0.1.14) (2019-07-23) | ||
@@ -233,6 +148,2 @@ | ||
## [0.1.13](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.12...@lion/ajax@0.1.13) (2019-07-23) | ||
@@ -242,17 +153,8 @@ | ||
## [0.1.12](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.11...@lion/ajax@0.1.12) (2019-06-03) | ||
### Bug Fixes | ||
* **ajax:** update to axios with security vularability fix ([d227a04](https://github.com/ing-bank/lion/commit/d227a04)) | ||
- **ajax:** update to axios with security vularability fix ([d227a04](https://github.com/ing-bank/lion/commit/d227a04)) | ||
## [0.1.11](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.10...@lion/ajax@0.1.11) (2019-05-29) | ||
@@ -262,6 +164,2 @@ | ||
## [0.1.10](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.9...@lion/ajax@0.1.10) (2019-05-24) | ||
@@ -271,6 +169,2 @@ | ||
## [0.1.9](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.8...@lion/ajax@0.1.9) (2019-05-22) | ||
@@ -280,6 +174,2 @@ | ||
## [0.1.8](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.7...@lion/ajax@0.1.8) (2019-05-17) | ||
@@ -289,6 +179,2 @@ | ||
## [0.1.7](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.6...@lion/ajax@0.1.7) (2019-05-16) | ||
@@ -298,39 +184,20 @@ | ||
## [0.1.6](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.5...@lion/ajax@0.1.6) (2019-05-13) | ||
### Bug Fixes | ||
* add prepublish step to make links absolute for npm docs ([9f2c4f6](https://github.com/ing-bank/lion/commit/9f2c4f6)) | ||
- add prepublish step to make links absolute for npm docs ([9f2c4f6](https://github.com/ing-bank/lion/commit/9f2c4f6)) | ||
## [0.1.5](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.4...@lion/ajax@0.1.5) (2019-05-07) | ||
### Bug Fixes | ||
* import from entry points so stories can be extended ([49f18a4](https://github.com/ing-bank/lion/commit/49f18a4)) | ||
- import from entry points so stories can be extended ([49f18a4](https://github.com/ing-bank/lion/commit/49f18a4)) | ||
## [0.1.4](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.3...@lion/ajax@0.1.4) (2019-04-28) | ||
### Bug Fixes | ||
* update storybook/linting; adjust story labels, eslint ignores ([8d96f84](https://github.com/ing-bank/lion/commit/8d96f84)) | ||
- update storybook/linting; adjust story labels, eslint ignores ([8d96f84](https://github.com/ing-bank/lion/commit/8d96f84)) | ||
## [0.1.3](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.2...@lion/ajax@0.1.3) (2019-04-27) | ||
@@ -340,33 +207,18 @@ | ||
## [0.1.2](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.1...@lion/ajax@0.1.2) (2019-04-27) | ||
### Bug Fixes | ||
* **ajax:** add setAjax to public api ([9a69b1a](https://github.com/ing-bank/lion/commit/9a69b1a)) | ||
- **ajax:** add setAjax to public api ([9a69b1a](https://github.com/ing-bank/lion/commit/9a69b1a)) | ||
## [0.1.1](https://github.com/ing-bank/lion/compare/@lion/ajax@0.1.0...@lion/ajax@0.1.1) (2019-04-26) | ||
### Bug Fixes | ||
* add missing files to npm packages ([0e3ca17](https://github.com/ing-bank/lion/commit/0e3ca17)) | ||
- add missing files to npm packages ([0e3ca17](https://github.com/ing-bank/lion/commit/0e3ca17)) | ||
# 0.1.0 (2019-04-26) | ||
### Features | ||
* release inital public lion version ([ec8da8f](https://github.com/ing-bank/lion/commit/ec8da8f)) | ||
- release inital public lion version ([ec8da8f](https://github.com/ing-bank/lion/commit/ec8da8f)) |
{ | ||
"name": "@lion/ajax", | ||
"version": "0.4.4", | ||
"version": "0.5.0", | ||
"description": "Thin wrapper around axios to allow for custom interceptors", | ||
@@ -34,4 +34,4 @@ "license": "MIT", | ||
"@bundled-es-modules/axios": "0.18.1", | ||
"@lion/core": "0.8.0", | ||
"singleton-manager": "1.1.1" | ||
"@lion/core": "0.9.0", | ||
"singleton-manager": "1.1.2" | ||
}, | ||
@@ -45,4 +45,3 @@ "keywords": [ | ||
"access": "public" | ||
}, | ||
"gitHead": "b7ea11c767cd3c3998db65c64aa9e36794fee0c2" | ||
} | ||
} |
@@ -94,3 +94,3 @@ # Ajax | ||
```js | ||
const myAjax = AjaxClass.getNewInstance({ jsonPrefix: ")]}'," }); | ||
const myAjax = new AjaxClass({ jsonPrefix: ")]}'," }); | ||
myAjax | ||
@@ -114,3 +114,3 @@ .get('./packages/ajax/docs/assets/data.json') | ||
@click=${() => { | ||
const myAjax = AjaxClass.getNewInstance({ headers: { 'MY-HEADER': 'SOME-HEADER-VALUE' } }); | ||
const myAjax = new AjaxClass({ headers: { 'MY-HEADER': 'SOME-HEADER-VALUE' } }); | ||
myAjax | ||
@@ -141,3 +141,3 @@ .get('./packages/ajax/docs/assets/data.json') | ||
@click=${() => { | ||
const myAjax = AjaxClass.getNewInstance({ cancelable: true }); | ||
const myAjax = new AjaxClass({ cancelable: true }); | ||
requestAnimationFrame(() => { | ||
@@ -169,3 +169,3 @@ myAjax.cancel('too slow'); | ||
@click=${() => { | ||
const myAjax = AjaxClass.getNewInstance({ cancelPreviousOnNewRequest: true }); | ||
const myAjax = new AjaxClass({ cancelPreviousOnNewRequest: true }); | ||
myAjax | ||
@@ -172,0 +172,0 @@ .get('./packages/ajax/docs/assets/data.json') |
@@ -7,3 +7,3 @@ import { singletonManager } from 'singleton-manager'; | ||
*/ | ||
export let ajax = singletonManager.get('@lion/ajax::ajax::0.3.x') || AjaxClass.getInstance(); // eslint-disable-line import/no-mutable-exports | ||
export let ajax = singletonManager.get('@lion/ajax::ajax::0.3.x') || new AjaxClass(); // eslint-disable-line import/no-mutable-exports | ||
@@ -10,0 +10,0 @@ /** |
import { axios } from '@bundled-es-modules/axios'; | ||
import { LionSingleton } from '@lion/core'; | ||
import { | ||
@@ -14,3 +13,3 @@ cancelInterceptorFactory, | ||
*/ | ||
export class AjaxClass extends LionSingleton { | ||
export class AjaxClass { | ||
/** | ||
@@ -32,4 +31,2 @@ * @property {Object} proxy the axios instance that is bound to the AjaxClass instance | ||
constructor(config) { | ||
super(); | ||
this.__config = { | ||
@@ -36,0 +33,0 @@ lang: document.documentElement.getAttribute('lang'), |
@@ -9,2 +9,6 @@ import { expect } from '@open-wc/testing'; | ||
function getInstance(cfg) { | ||
return new AjaxClass(cfg); | ||
} | ||
beforeEach(() => { | ||
@@ -28,4 +32,4 @@ server = sinon.fakeServer.create({ autoRespond: true }); | ||
} | ||
const ajaxWithout = AjaxClass.getNewInstance(); | ||
const ajaxWith = MyApi.getNewInstance(); | ||
const ajaxWithout = getInstance(); | ||
const ajaxWith = new MyApi(); | ||
expect(ajaxWithout[type]).to.not.include(myInterceptor); | ||
@@ -39,4 +43,4 @@ expect(ajaxWith[type]).to.include(myInterceptor); | ||
const myInterceptor = () => {}; | ||
const ajaxWithout = AjaxClass.getNewInstance(); | ||
const ajaxWith = AjaxClass.getNewInstance(); | ||
const ajaxWithout = getInstance(); | ||
const ajaxWith = getInstance(); | ||
ajaxWith[type].push(myInterceptor); | ||
@@ -59,3 +63,3 @@ expect(ajaxWithout[type]).to.not.include(myInterceptor); | ||
const ajax = AjaxClass.getNewInstance(); | ||
const ajax = getInstance(); | ||
@@ -75,3 +79,3 @@ ajax[type].push(myInterceptor); | ||
server.respondWith('GET', 'data.json', [200, { 'Content-Type': 'application/json' }, '{}']); | ||
const ajax = AjaxClass.getNewInstance(); | ||
const ajax = getInstance(); | ||
ajax.options.myCustomValue = 'foo'; | ||
@@ -102,3 +106,3 @@ let customValueAccess = false; | ||
const enforcePutInterceptor = config => ({ ...config, method: 'PUT' }); | ||
const myAjax = AjaxClass.getNewInstance(); | ||
const myAjax = getInstance(); | ||
myAjax.requestInterceptors.push(enforcePutInterceptor); | ||
@@ -121,3 +125,3 @@ const response = await myAjax.post('data.json'); | ||
}); | ||
const myAjax = AjaxClass.getNewInstance(); | ||
const myAjax = getInstance(); | ||
myAjax.responseInterceptors.push(addDataInterceptor); | ||
@@ -124,0 +128,0 @@ const response = await myAjax.get('data.json'); |
@@ -10,2 +10,6 @@ import { expect } from '@open-wc/testing'; | ||
function getInstance(cfg) { | ||
return new AjaxClass(cfg); | ||
} | ||
beforeEach(() => { | ||
@@ -20,3 +24,3 @@ server = sinon.fakeServer.create({ autoRespond: true }); | ||
it('sets content type json if passed an object', async () => { | ||
const myAjax = AjaxClass.getNewInstance(); | ||
const myAjax = getInstance(); | ||
server.respondWith('POST', /\/api\/foo/, [200, { 'Content-Type': 'application/json' }, '']); | ||
@@ -27,6 +31,6 @@ await myAjax.post('/api/foo', { a: 1, b: 2 }); | ||
describe('AjaxClass.getNewInstance({ jsonPrefix: "%prefix%" })', () => { | ||
describe('AjaxClass({ jsonPrefix: "%prefix%" })', () => { | ||
it('adds new transformer to responseDataTransformers', () => { | ||
const myAjaxWithout = AjaxClass.getNewInstance({ jsonPrefix: '' }); | ||
const myAjaxWith = AjaxClass.getNewInstance({ jsonPrefix: 'prefix' }); | ||
const myAjaxWithout = getInstance({ jsonPrefix: '' }); | ||
const myAjaxWith = getInstance({ jsonPrefix: 'prefix' }); | ||
const lengthWithout = myAjaxWithout.responseDataTransformers.length; | ||
@@ -44,3 +48,3 @@ const lengthWith = myAjaxWith.responseDataTransformers.length; | ||
const myAjax = AjaxClass.getNewInstance({ jsonPrefix: 'for(;;);' }); | ||
const myAjax = getInstance({ jsonPrefix: 'for(;;);' }); | ||
const response = await myAjax.get('data.json'); | ||
@@ -54,3 +58,3 @@ expect(response.status).to.equal(200); | ||
const myAjax = AjaxClass.getNewInstance({ jsonPrefix: 'for(;;);' }); | ||
const myAjax = getInstance({ jsonPrefix: 'for(;;);' }); | ||
const response = await myAjax.get('data.txt'); | ||
@@ -62,6 +66,6 @@ expect(response.status).to.equal(200); | ||
describe('AjaxClass.getNewInstance({ cancelable: true })', () => { | ||
describe('AjaxClass({ cancelable: true })', () => { | ||
it('adds new interceptor to requestInterceptors', () => { | ||
const myAjaxWithout = AjaxClass.getNewInstance(); | ||
const myAjaxWith = AjaxClass.getNewInstance({ cancelable: true }); | ||
const myAjaxWithout = getInstance(); | ||
const myAjaxWith = getInstance({ cancelable: true }); | ||
const lengthWithout = myAjaxWithout.requestInterceptors.length; | ||
@@ -73,3 +77,3 @@ const lengthWith = myAjaxWith.requestInterceptors.length; | ||
it('allows to cancel single running requests', async () => { | ||
const myAjax = AjaxClass.getNewInstance({ cancelable: true }); | ||
const myAjax = getInstance({ cancelable: true }); | ||
@@ -89,3 +93,3 @@ setTimeout(() => { | ||
it('allows to cancel multiple running requests', async () => { | ||
const myAjax = AjaxClass.getNewInstance({ cancelable: true }); | ||
const myAjax = getInstance({ cancelable: true }); | ||
let cancelCount = 0; | ||
@@ -113,3 +117,3 @@ | ||
it('does not cancel resolved requests', async () => { | ||
const myAjax = AjaxClass.getNewInstance({ cancelable: true }); | ||
const myAjax = getInstance({ cancelable: true }); | ||
server.respondWith('GET', 'data.json', [ | ||
@@ -131,6 +135,6 @@ 200, | ||
describe('AjaxClass.getNewInstance({ cancelPreviousOnNewRequest: true })', () => { | ||
describe('AjaxClass({ cancelPreviousOnNewRequest: true })', () => { | ||
it('adds new interceptor to requestInterceptors', () => { | ||
const myAjaxWithout = AjaxClass.getNewInstance(); | ||
const myAjaxWith = AjaxClass.getNewInstance({ cancelPreviousOnNewRequest: true }); | ||
const myAjaxWithout = getInstance(); | ||
const myAjaxWith = getInstance({ cancelPreviousOnNewRequest: true }); | ||
const lengthWithout = myAjaxWithout.requestInterceptors.length; | ||
@@ -142,3 +146,3 @@ const lengthWith = myAjaxWith.requestInterceptors.length; | ||
it('automatically cancels previous running request', async () => { | ||
const myAjax = AjaxClass.getNewInstance({ cancelPreviousOnNewRequest: true }); | ||
const myAjax = getInstance({ cancelPreviousOnNewRequest: true }); | ||
server.respondWith('GET', 'data.json', [ | ||
@@ -171,3 +175,3 @@ 200, | ||
it('automatically cancels multiple previous requests to the same endpoint', async () => { | ||
const myAjax = AjaxClass.getNewInstance({ cancelPreviousOnNewRequest: true }); | ||
const myAjax = getInstance({ cancelPreviousOnNewRequest: true }); | ||
server.respondWith('GET', 'data.json', [ | ||
@@ -204,3 +208,3 @@ 200, | ||
it('automatically cancels multiple previous requests to different endpoints', async () => { | ||
const myAjax = AjaxClass.getNewInstance({ cancelPreviousOnNewRequest: true }); | ||
const myAjax = getInstance({ cancelPreviousOnNewRequest: true }); | ||
server.respondWith('GET', 'data.json', [ | ||
@@ -237,3 +241,3 @@ 200, | ||
it('does not automatically cancel requests made via generic ajax', async () => { | ||
const myAjax = AjaxClass.getNewInstance({ cancelPreviousOnNewRequest: true }); | ||
const myAjax = getInstance({ cancelPreviousOnNewRequest: true }); | ||
server.respondWith('GET', 'data.json', [ | ||
@@ -274,4 +278,4 @@ 200, | ||
it('does not automatically cancel requests made via other instances', async () => { | ||
const myAjax1 = AjaxClass.getNewInstance({ cancelPreviousOnNewRequest: true }); | ||
const myAjax2 = AjaxClass.getNewInstance({ cancelPreviousOnNewRequest: true }); | ||
const myAjax1 = getInstance({ cancelPreviousOnNewRequest: true }); | ||
const myAjax2 = getInstance({ cancelPreviousOnNewRequest: true }); | ||
server.respondWith('GET', 'data.json', [ | ||
@@ -278,0 +282,0 @@ 200, |
@@ -9,2 +9,6 @@ import { expect } from '@open-wc/testing'; | ||
function getInstance(cfg) { | ||
return new AjaxClass(cfg); | ||
} | ||
beforeEach(() => { | ||
@@ -28,4 +32,4 @@ server = sinon.fakeServer.create({ autoRespond: true }); | ||
} | ||
const ajaxWithout = AjaxClass.getNewInstance(); | ||
const ajaxWith = MyApi.getNewInstance(); | ||
const ajaxWithout = getInstance(); | ||
const ajaxWith = new MyApi(); | ||
expect(ajaxWithout[type]).to.not.include(myInterceptor); | ||
@@ -36,7 +40,7 @@ expect(ajaxWith[type]).to.include(myInterceptor); | ||
it('can be added per instance withour changing the class', () => { | ||
it('can be added per instance without changing the class', () => { | ||
['requestDataTransformers', 'responseDataTransformers'].forEach(type => { | ||
const myInterceptor = () => {}; | ||
const ajaxWithout = AjaxClass.getNewInstance(); | ||
const ajaxWith = AjaxClass.getNewInstance(); | ||
const ajaxWithout = getInstance(); | ||
const ajaxWith = getInstance(); | ||
ajaxWith[type].push(myInterceptor); | ||
@@ -59,3 +63,3 @@ expect(ajaxWithout[type]).to.not.include(myInterceptor); | ||
const ajax = AjaxClass.getNewInstance(); | ||
const ajax = getInstance(); | ||
@@ -82,3 +86,3 @@ ajax[type].push(myTransformer); | ||
const addBarTransformer = data => ({ ...data, bar: 'bar' }); | ||
const myAjax = AjaxClass.getNewInstance(); | ||
const myAjax = getInstance(); | ||
myAjax.requestDataTransformers.push(addBarTransformer); | ||
@@ -101,3 +105,3 @@ const response = await myAjax.post('data.json', { foo: 'foo' }); | ||
const addBarTransformer = data => ({ ...data, bar: 'bar' }); | ||
const myAjax = AjaxClass.getNewInstance(); | ||
const myAjax = getInstance(); | ||
myAjax.responseDataTransformers.push(addBarTransformer); | ||
@@ -104,0 +108,0 @@ const response = await myAjax.get('data.json'); |
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
923
47815
14
+ Added@lion/core@0.9.0(transitive)
+ Addedsingleton-manager@1.1.2(transitive)
- Removed@lion/core@0.8.0(transitive)
- Removedsingleton-manager@1.1.1(transitive)
Updated@lion/core@0.9.0
Updatedsingleton-manager@1.1.2