@atlaskit/util-service-support
Advanced tools
Comparing version 3.1.0 to 3.1.1
# @atlaskit/util-service-support | ||
## 3.1.1 | ||
- Updated dependencies [76299208e6](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/76299208e6): | ||
- @atlaskit/docs@7.0.0 | ||
## 3.1.0 | ||
@@ -4,0 +8,0 @@ - [minor] [1d19234fbd](https://bitbucket.org/atlassian/atlaskit-mk-2/commits/1d19234fbd): |
{ | ||
"name": "@atlaskit/util-service-support", | ||
"version": "3.1.0" | ||
"version": "3.1.1" | ||
} |
{ | ||
"name": "@atlaskit/util-service-support", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "A library of support classes for integrating React components with REST HTTP services", | ||
@@ -33,4 +33,3 @@ "config": { | ||
"devDependencies": { | ||
"@atlaskit/docs": "^6.0.0", | ||
"chai": "^4.1.2", | ||
"@atlaskit/docs": "^7.0.0", | ||
"es6-promise": "^4.0.5", | ||
@@ -46,2 +45,2 @@ "fetch-mock": "^6.5.2", | ||
] | ||
} | ||
} |
import 'es6-promise/auto'; // 'whatwg-fetch' needs a Promise polyfill | ||
import 'whatwg-fetch'; | ||
import { expect } from 'chai'; | ||
import * as fetchMock from 'fetch-mock/src/client'; | ||
@@ -52,3 +51,3 @@ | ||
return requestService(serviceConfig).then(response => { | ||
expect(response).to.deep.equal(defaultResponse); | ||
expect(response).toEqual(defaultResponse); | ||
}); | ||
@@ -78,18 +77,14 @@ }); | ||
return requestService(serviceConfig, options).then(response => { | ||
expect(response).to.deep.equal(defaultResponse); | ||
expect(response).toEqual(defaultResponse); | ||
const calls = fetchMock.calls('request'); | ||
expect(calls.length, 'Fetch calls').to.equal(1); | ||
expect(calls.length).toEqual(1); | ||
const url = calls[0][0]; | ||
const { headers, method } = calls[0][1]; | ||
const xCheeseHeader = headers.map['x-cheese']; | ||
expect(xCheeseHeader, 'Header defined').to.not.equal(undefined); | ||
expect(xCheeseHeader, 'Header value').to.equal('american'); | ||
expect(url.indexOf(url), `url starts with ${url}`).to.equal(0); | ||
expect(url.indexOf('sauce=tomato') >= 0, 'sauce query param').to.equal( | ||
true, | ||
); | ||
expect(url.indexOf('bacon=nice') >= 0, 'sauce query param').to.equal( | ||
true, | ||
); | ||
expect(method, 'method').to.equal('POST'); | ||
expect(xCheeseHeader).not.toEqual(undefined); | ||
expect(xCheeseHeader).toEqual('american'); | ||
expect(url.indexOf(url)).toEqual(0); | ||
expect(url.indexOf('sauce=tomato') >= 0).toEqual(true); | ||
expect(url.indexOf('bacon=nice') >= 0).toEqual(true); | ||
expect(method).toEqual('POST'); | ||
}); | ||
@@ -109,4 +104,4 @@ }); | ||
const calls = fetchMock.calls('request'); | ||
expect(calls.length, 'Fetch calls').to.equal(1); | ||
expect(error.code).to.equal(401); | ||
expect(calls.length).toEqual(1); | ||
expect(error.code).toEqual(401); | ||
}); | ||
@@ -133,5 +128,5 @@ }); | ||
}; | ||
return requestService(serviceConfig).then(response => { | ||
return requestService(serviceConfig).then(() => { | ||
const refreshCalls = fetchMock.calls('request'); | ||
expect(refreshCalls.length, 'Second request').to.equal(1); | ||
expect(refreshCalls.length).toEqual(1); | ||
const url = refreshCalls[0][0]; | ||
@@ -141,8 +136,6 @@ const { headers } = refreshCalls[0][1]; | ||
const xCheeseHeader = headers.map['x-cheese']; | ||
expect(xCheeseHeader, 'Header defined').to.not.equal(undefined); | ||
expect(xCheeseHeader, 'Header value').to.equal('swiss'); | ||
expect(url.indexOf(url), `url starts with ${url}`).to.equal(0); | ||
expect(url.indexOf('bacon=crispy') >= 0, 'sauce query param').to.equal( | ||
true, | ||
); | ||
expect(xCheeseHeader).not.toEqual(undefined); | ||
expect(xCheeseHeader).toEqual('swiss'); | ||
expect(url.indexOf(url)).toEqual(0); | ||
expect(url.indexOf('bacon=crispy') >= 0).toEqual(true); | ||
}); | ||
@@ -161,5 +154,5 @@ }); | ||
return requestService(serviceConfig) | ||
.then(() => expect(true).to.equal(true)) | ||
.catch(() => expect(false).to.equal(true)); // should not error | ||
.then(() => expect(true).toEqual(true)) | ||
.catch(() => expect(false).toEqual(true)); // should not error | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
5
50537
1058