cozy-client 27.14.0 → 27.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/CozyClient.js +1 -1
- package/dist/CozyClient.spec.js +20 -20
- package/dist/associations.spec.js +1 -1
- package/dist/hooks/useQuery.spec.jsx +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [27.14.1](https://github.com/cozy/cozy-client/compare/v27.14.0...v27.14.1) (2022-01-28)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package cozy-client
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [27.14.0](https://github.com/cozy/cozy-client/compare/v27.13.0...v27.14.0) (2022-01-25)
|
|
7
15
|
|
|
8
16
|
|
package/dist/CozyClient.js
CHANGED
|
@@ -2463,7 +2463,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2463
2463
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2464
2464
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2465
2465
|
|
|
2466
|
-
CozyClient.version = "27.14.
|
|
2466
|
+
CozyClient.version = "27.14.1";
|
|
2467
2467
|
|
|
2468
2468
|
_microee.default.mixin(CozyClient);
|
|
2469
2469
|
|
package/dist/CozyClient.spec.js
CHANGED
|
@@ -1140,7 +1140,7 @@ describe('CozyClient', () => {
|
|
|
1140
1140
|
})
|
|
1141
1141
|
|
|
1142
1142
|
it('should first dispatch a INIT_QUERY action', async () => {
|
|
1143
|
-
requestHandler.
|
|
1143
|
+
requestHandler.mockResolvedValueOnce(fakeResponse)
|
|
1144
1144
|
await client.query(query, { as: 'allTodos' })
|
|
1145
1145
|
expect(client.store.dispatch.mock.calls[0][0]).toEqual(
|
|
1146
1146
|
initQuery('allTodos', { doctype: 'io.cozy.todos' }, { as: 'allTodos' })
|
|
@@ -1148,7 +1148,7 @@ describe('CozyClient', () => {
|
|
|
1148
1148
|
})
|
|
1149
1149
|
|
|
1150
1150
|
it('should then dispatch a RECEIVE_QUERY_RESULT action', async () => {
|
|
1151
|
-
requestHandler.
|
|
1151
|
+
requestHandler.mockResolvedValueOnce(fakeResponse)
|
|
1152
1152
|
await client.query(query, { as: 'allTodos' })
|
|
1153
1153
|
const dispatchCalls = client.store.dispatch.mock.calls
|
|
1154
1154
|
const lastDispatchCall = dispatchCalls[dispatchCalls.length - 1]
|
|
@@ -1159,7 +1159,7 @@ describe('CozyClient', () => {
|
|
|
1159
1159
|
|
|
1160
1160
|
it('should dispatch a RECEIVE_QUERY_ERROR action if an error occurs', async () => {
|
|
1161
1161
|
const error = new Error('Fake error')
|
|
1162
|
-
requestHandler.
|
|
1162
|
+
requestHandler.mockRejectedValueOnce(error)
|
|
1163
1163
|
try {
|
|
1164
1164
|
await client.query(query, { as: 'allTodos' })
|
|
1165
1165
|
} catch (e) {} // eslint-disable-line no-empty
|
|
@@ -1169,13 +1169,13 @@ describe('CozyClient', () => {
|
|
|
1169
1169
|
})
|
|
1170
1170
|
|
|
1171
1171
|
it('should resolve to the query response', async () => {
|
|
1172
|
-
requestHandler.
|
|
1172
|
+
requestHandler.mockResolvedValueOnce(fakeResponse)
|
|
1173
1173
|
const resp = await client.query(query)
|
|
1174
1174
|
expect(resp).toEqual(fakeResponse)
|
|
1175
1175
|
})
|
|
1176
1176
|
|
|
1177
1177
|
it('should call the link with the query', async () => {
|
|
1178
|
-
requestHandler.
|
|
1178
|
+
requestHandler.mockResolvedValueOnce(fakeResponse)
|
|
1179
1179
|
await client.query(query)
|
|
1180
1180
|
expect(requestHandler).toHaveBeenCalledTimes(1)
|
|
1181
1181
|
expect(requestHandler.mock.calls[0][0]).toBe(query)
|
|
@@ -1200,8 +1200,8 @@ describe('CozyClient', () => {
|
|
|
1200
1200
|
]
|
|
1201
1201
|
})
|
|
1202
1202
|
)
|
|
1203
|
-
.
|
|
1204
|
-
.
|
|
1203
|
+
.mockResolvedValueOnce({ data: [], included: [] })
|
|
1204
|
+
.mockResolvedValueOnce({ data: [], included: [] })
|
|
1205
1205
|
|
|
1206
1206
|
const resp = await client.query(
|
|
1207
1207
|
Q('io.cozy.todos').include(['attachments'])
|
|
@@ -1246,7 +1246,7 @@ describe('CozyClient', () => {
|
|
|
1246
1246
|
})
|
|
1247
1247
|
|
|
1248
1248
|
it('should set the correct name to the query', async () => {
|
|
1249
|
-
requestHandler.
|
|
1249
|
+
requestHandler.mockResolvedValueOnce(fakeResponse)
|
|
1250
1250
|
const getById = Q('io.cozy.files').getById('1')
|
|
1251
1251
|
await client.query(getById)
|
|
1252
1252
|
expect(client.store.dispatch.mock.calls[0][0]).toEqual(
|
|
@@ -1256,7 +1256,7 @@ describe('CozyClient', () => {
|
|
|
1256
1256
|
)
|
|
1257
1257
|
})
|
|
1258
1258
|
it('should use the name passed as an argument', async () => {
|
|
1259
|
-
requestHandler.
|
|
1259
|
+
requestHandler.mockResolvedValueOnce(fakeResponse)
|
|
1260
1260
|
const getById = Q('io.cozy.files').getById('1')
|
|
1261
1261
|
await client.query(getById, { as: 'toto' })
|
|
1262
1262
|
expect(client.store.dispatch.mock.calls[0][0]).toEqual(
|
|
@@ -1266,7 +1266,7 @@ describe('CozyClient', () => {
|
|
|
1266
1266
|
)
|
|
1267
1267
|
})
|
|
1268
1268
|
it('should name the query correctly', async () => {
|
|
1269
|
-
requestHandler.
|
|
1269
|
+
requestHandler.mockResolvedValueOnce(fakeResponse)
|
|
1270
1270
|
await client.query(query, { as: 'allTodos' })
|
|
1271
1271
|
expect(client.store.dispatch.mock.calls[0][0]).toEqual(
|
|
1272
1272
|
initQuery('allTodos', { doctype: 'io.cozy.todos' }, { as: 'allTodos' })
|
|
@@ -1353,7 +1353,7 @@ describe('CozyClient', () => {
|
|
|
1353
1353
|
})
|
|
1354
1354
|
|
|
1355
1355
|
it('should dispatch a INIT_QUERY action if status is not loaded', async () => {
|
|
1356
|
-
requestHandler.
|
|
1356
|
+
requestHandler.mockResolvedValueOnce(fakeResponse)
|
|
1357
1357
|
getQueryFromState.mockReturnValueOnce({
|
|
1358
1358
|
fetchStatus: 'pending'
|
|
1359
1359
|
})
|
|
@@ -1364,7 +1364,7 @@ describe('CozyClient', () => {
|
|
|
1364
1364
|
})
|
|
1365
1365
|
|
|
1366
1366
|
it('should dispatch a INIT_QUERY action if no skip and no bookmark', async () => {
|
|
1367
|
-
requestHandler.
|
|
1367
|
+
requestHandler.mockResolvedValueOnce(fakeResponse)
|
|
1368
1368
|
getQueryFromState.mockReturnValueOnce({
|
|
1369
1369
|
fetchStatus: 'loaded'
|
|
1370
1370
|
})
|
|
@@ -1375,7 +1375,7 @@ describe('CozyClient', () => {
|
|
|
1375
1375
|
})
|
|
1376
1376
|
|
|
1377
1377
|
it('should dispatch a RECEIVE_QUERY_RESULT action if query has skip', async () => {
|
|
1378
|
-
requestHandler.
|
|
1378
|
+
requestHandler.mockResolvedValueOnce(fakeResponse)
|
|
1379
1379
|
getQueryFromState.mockReturnValueOnce({
|
|
1380
1380
|
fetchStatus: 'loaded'
|
|
1381
1381
|
})
|
|
@@ -1389,7 +1389,7 @@ describe('CozyClient', () => {
|
|
|
1389
1389
|
})
|
|
1390
1390
|
|
|
1391
1391
|
it('should dispatch a RECEIVE_QUERY_RESULT action if query has bookmark', async () => {
|
|
1392
|
-
requestHandler.
|
|
1392
|
+
requestHandler.mockResolvedValueOnce(fakeResponse)
|
|
1393
1393
|
getQueryFromState.mockReturnValueOnce({
|
|
1394
1394
|
fetchStatus: 'loaded'
|
|
1395
1395
|
})
|
|
@@ -1404,7 +1404,7 @@ describe('CozyClient', () => {
|
|
|
1404
1404
|
|
|
1405
1405
|
const setupOnError = () => {
|
|
1406
1406
|
const error = new TypeError('Failed to fetch')
|
|
1407
|
-
requestHandler.
|
|
1407
|
+
requestHandler.mockRejectedValueOnce(error)
|
|
1408
1408
|
const onError = jest.fn().mockReturnValueOnce(() => true)
|
|
1409
1409
|
return onError
|
|
1410
1410
|
}
|
|
@@ -1443,7 +1443,7 @@ describe('CozyClient', () => {
|
|
|
1443
1443
|
|
|
1444
1444
|
it('should throw an error when there is no onError callback', async () => {
|
|
1445
1445
|
const error = new TypeError('Failed to fetch')
|
|
1446
|
-
requestHandler.
|
|
1446
|
+
requestHandler.mockRejectedValueOnce(error)
|
|
1447
1447
|
|
|
1448
1448
|
await expect(client.query(query, { as: 'allTodos' })).rejects.toThrow(
|
|
1449
1449
|
'Failed to fetch'
|
|
@@ -1546,7 +1546,7 @@ describe('CozyClient', () => {
|
|
|
1546
1546
|
})
|
|
1547
1547
|
|
|
1548
1548
|
it('should then dispatch a RECEIVE_MUTATION_RESULT action', async () => {
|
|
1549
|
-
requestHandler.
|
|
1549
|
+
requestHandler.mockResolvedValueOnce(fakeResponse)
|
|
1550
1550
|
await client.mutate(mutation, { as: 'updateTodo' })
|
|
1551
1551
|
expect(client.store.dispatch.mock.calls[1][0]).toEqual(
|
|
1552
1552
|
receiveMutationResult('updateTodo', fakeResponse, {}, mutation)
|
|
@@ -1554,14 +1554,14 @@ describe('CozyClient', () => {
|
|
|
1554
1554
|
})
|
|
1555
1555
|
|
|
1556
1556
|
it('should resolve to the mutation response', async () => {
|
|
1557
|
-
requestHandler.
|
|
1557
|
+
requestHandler.mockResolvedValueOnce(fakeResponse)
|
|
1558
1558
|
const resp = await client.mutate(mutation)
|
|
1559
1559
|
expect(resp).toEqual(fakeResponse)
|
|
1560
1560
|
})
|
|
1561
1561
|
|
|
1562
1562
|
it('should dispatch a RECEIVE_MUTATION_ERROR action if an error occurs', async () => {
|
|
1563
1563
|
const error = new Error('Fake error')
|
|
1564
|
-
requestHandler.
|
|
1564
|
+
requestHandler.mockRejectedValueOnce(error)
|
|
1565
1565
|
try {
|
|
1566
1566
|
await client.mutate(mutation, { as: 'updateTodo' })
|
|
1567
1567
|
} catch (e) {} // eslint-disable-line no-empty
|
|
@@ -1573,7 +1573,7 @@ describe('CozyClient', () => {
|
|
|
1573
1573
|
it('should handle an array of mutations (including mutation creators)', async () => {
|
|
1574
1574
|
const FAKE_MUTATION_1 = { mutationType: 'FAKE_1' }
|
|
1575
1575
|
const FAKE_MUTATION_2 = resp => ({ mutationType: 'FAKE_2', resp })
|
|
1576
|
-
requestHandler.
|
|
1576
|
+
requestHandler.mockResolvedValue(fakeResponse)
|
|
1577
1577
|
await client.mutate([mutation, FAKE_MUTATION_1, FAKE_MUTATION_2])
|
|
1578
1578
|
expect(requestHandler).toHaveBeenCalledTimes(3)
|
|
1579
1579
|
expect(requestHandler.mock.calls[0][0]).toBe(mutation)
|
|
@@ -119,7 +119,7 @@ describe('Associations', () => {
|
|
|
119
119
|
],
|
|
120
120
|
next: false
|
|
121
121
|
}
|
|
122
|
-
requestHandler.
|
|
122
|
+
requestHandler.mockResolvedValueOnce(FAKE_RESPONSE)
|
|
123
123
|
|
|
124
124
|
const queryBefore = getQueryFromStore(client.store, 'allTodos')
|
|
125
125
|
await getTodo(TODO_1._id).attachments.fetchMore()
|
|
@@ -214,7 +214,7 @@ describe('use query', () => {
|
|
|
214
214
|
links: [new CozyLink(requestHandler)]
|
|
215
215
|
})
|
|
216
216
|
const error = new TypeError('Failed to fetch')
|
|
217
|
-
requestHandler.
|
|
217
|
+
requestHandler.mockRejectedValue(error)
|
|
218
218
|
const onError = jest.fn().mockReturnValue(() => true)
|
|
219
219
|
setupQuery({
|
|
220
220
|
customClient: client,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "27.14.
|
|
3
|
+
"version": "27.14.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"cozy-device-helper": "^1.12.0",
|
|
22
22
|
"cozy-flags": "2.7.1",
|
|
23
23
|
"cozy-logger": "^1.6.0",
|
|
24
|
-
"cozy-stack-client": "^27.
|
|
24
|
+
"cozy-stack-client": "^27.14.1",
|
|
25
25
|
"json-stable-stringify": "^1.0.1",
|
|
26
26
|
"lodash": "^4.17.13",
|
|
27
27
|
"microee": "^0.0.6",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
|
|
72
72
|
},
|
|
73
73
|
"sideEffects": false,
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "e4c1705391124b583bcaa0ce63b44b39358ed798"
|
|
75
75
|
}
|