Skip to content

Commit f0e1877

Browse files
committed
fix: Actually test that the response is sealed
Before, this was testing the response object passed to callbacks which is not currently the same object than the one processed in the lib.
1 parent fab53a6 commit f0e1877

File tree

2 files changed

+2
-15
lines changed

2 files changed

+2
-15
lines changed

test/api/Api-requests.spec.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,21 +51,10 @@ test('executes error callbacks', async () => {
5151
})
5252

5353
test('response is sealed', async () => {
54-
const newProp = (response) => {
54+
await expect(api.get('/').then(response => {
5555
response.new_prop = 'test'
56-
}
57-
58-
api.addSuccessCallback(newProp)
59-
await expect(api.get('/')).rejects.toThrowErrorMatchingSnapshot()
60-
61-
const changeProp = (response) => {
6256
response.ok = false
63-
}
64-
65-
api.resetSuccessCallbacks()
66-
api.addSuccessCallback(changeProp)
67-
68-
await expect(api.get('/')).rejects.toThrowErrorMatchingSnapshot()
57+
})).rejects.toThrowErrorMatchingSnapshot()
6958
})
7059

7160
test('verb methods pass to _doRequest', () => {
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`response is sealed 1`] = `"Cannot define property new_prop, object is not extensible"`;
4-
5-
exports[`response is sealed 2`] = `"Cannot set property ok of #<Response> which has only a getter"`;

0 commit comments

Comments
 (0)