cozy-client 27.14.1 → 27.14.2
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 +2 -1
- package/dist/CozyClient.spec.js +38 -36
- package/dist/utils.spec.js +1 -0
- package/package.json +2 -2
- package/types/CozyClient.d.ts +1 -0
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.2](https://github.com/cozy/cozy-client/compare/v27.14.1...v27.14.2) (2022-01-28)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package cozy-client
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [27.14.1](https://github.com/cozy/cozy-client/compare/v27.14.0...v27.14.1) (2022-01-28)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package cozy-client
|
package/dist/CozyClient.js
CHANGED
|
@@ -2293,6 +2293,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2293
2293
|
* At any time put an error function
|
|
2294
2294
|
*
|
|
2295
2295
|
* @param {Function} [onError] - Set a callback for queries which are errored
|
|
2296
|
+
* @throws {Error} onError should not have been defined yet
|
|
2296
2297
|
*/
|
|
2297
2298
|
|
|
2298
2299
|
}, {
|
|
@@ -2463,7 +2464,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2463
2464
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2464
2465
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2465
2466
|
|
|
2466
|
-
CozyClient.version = "27.14.
|
|
2467
|
+
CozyClient.version = "27.14.2";
|
|
2467
2468
|
|
|
2468
2469
|
_microee.default.mixin(CozyClient);
|
|
2469
2470
|
|
package/dist/CozyClient.spec.js
CHANGED
|
@@ -1402,52 +1402,54 @@ describe('CozyClient', () => {
|
|
|
1402
1402
|
)
|
|
1403
1403
|
})
|
|
1404
1404
|
|
|
1405
|
-
|
|
1406
|
-
const
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1405
|
+
describe('setupOnError', () => {
|
|
1406
|
+
const setupOnError = () => {
|
|
1407
|
+
const error = new TypeError('Failed to fetch')
|
|
1408
|
+
requestHandler.mockRejectedValueOnce(error)
|
|
1409
|
+
return jest.fn().mockReturnValueOnce(() => true)
|
|
1410
|
+
}
|
|
1411
1411
|
|
|
1412
|
-
|
|
1413
|
-
|
|
1412
|
+
it('should call onError callback when an error is thrown. Callback passed as argument', async () => {
|
|
1413
|
+
const onError = setupOnError()
|
|
1414
1414
|
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1415
|
+
await client.query(query, { as: 'allTodos', onError })
|
|
1416
|
+
expect(onError).toBeCalled()
|
|
1417
|
+
})
|
|
1418
1418
|
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1419
|
+
it('should call onError callback when an error is caught. It is passed during instantiation', async () => {
|
|
1420
|
+
const setupOnError = () => jest.fn().mockReturnValueOnce(() => true)
|
|
1421
|
+
const onError = setupOnError()
|
|
1422
|
+
const client = new CozyClient({ onError })
|
|
1422
1423
|
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1424
|
+
await client.query(query, { as: 'allTodos' })
|
|
1425
|
+
expect(onError).toBeCalled()
|
|
1426
|
+
})
|
|
1426
1427
|
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1428
|
+
it('should call onError callback when an error is catched. It is passed with setOnError', async () => {
|
|
1429
|
+
const onError = setupOnError()
|
|
1430
|
+
client.setOnError(onError)
|
|
1430
1431
|
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1432
|
+
await client.query(query, { as: 'allTodos' })
|
|
1433
|
+
expect(onError).toBeCalled()
|
|
1434
|
+
})
|
|
1434
1435
|
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1436
|
+
it('should throw an error when we call setOnError twice (or several times)', async () => {
|
|
1437
|
+
const client = new CozyClient({})
|
|
1438
|
+
const onError = () => true
|
|
1438
1439
|
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1440
|
+
const funcShouldThrow = () => client.setOnError(onError)
|
|
1441
|
+
expect(funcShouldThrow).not.toThrow()
|
|
1442
|
+
expect(funcShouldThrow).toThrow('On Error is already defined')
|
|
1443
|
+
})
|
|
1443
1444
|
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1445
|
+
it('should throw an error when there is no onError callback', async () => {
|
|
1446
|
+
const error = new TypeError('Failed to fetch')
|
|
1447
|
+
requestHandler.mockRejectedValueOnce(error)
|
|
1447
1448
|
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1449
|
+
await expect(client.query(query, { as: 'allTodos' })).rejects.toThrow(
|
|
1450
|
+
'Failed to fetch'
|
|
1451
|
+
)
|
|
1452
|
+
})
|
|
1451
1453
|
})
|
|
1452
1454
|
})
|
|
1453
1455
|
|
package/dist/utils.spec.js
CHANGED
|
@@ -22,6 +22,7 @@ describe('cancelable', () => {
|
|
|
22
22
|
})
|
|
23
23
|
|
|
24
24
|
it('should reject with the rejection of the promise', done => {
|
|
25
|
+
jest.spyOn(console, 'log').mockImplementation()
|
|
25
26
|
const error = 'normal-rejection-from-cancelable-test'
|
|
26
27
|
const { reject, wrapped } = setup()
|
|
27
28
|
expect.assertions(1)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "27.14.
|
|
3
|
+
"version": "27.14.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -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": "c4f8d6121a6e97429fbfda1a2a1973100418afee"
|
|
75
75
|
}
|
package/types/CozyClient.d.ts
CHANGED
|
@@ -652,6 +652,7 @@ declare class CozyClient {
|
|
|
652
652
|
* At any time put an error function
|
|
653
653
|
*
|
|
654
654
|
* @param {Function} [onError] - Set a callback for queries which are errored
|
|
655
|
+
* @throws {Error} onError should not have been defined yet
|
|
655
656
|
*/
|
|
656
657
|
setOnError(onError?: Function): void;
|
|
657
658
|
toJSON(): SnapshotClient;
|