cozy-client 34.6.1 → 34.6.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/dist/CozyClient.js +1 -1
- package/dist/hooks/useQuery.js +7 -2
- package/dist/hooks/useQuery.spec.jsx +34 -1
- package/package.json +2 -2
package/dist/CozyClient.js
CHANGED
|
@@ -2644,7 +2644,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2644
2644
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2645
2645
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2646
2646
|
|
|
2647
|
-
CozyClient.version = "34.6.
|
|
2647
|
+
CozyClient.version = "34.6.2";
|
|
2648
2648
|
|
|
2649
2649
|
_microee.default.mixin(CozyClient);
|
|
2650
2650
|
|
package/dist/hooks/useQuery.js
CHANGED
|
@@ -60,10 +60,15 @@ var useQuery = function useQuery(queryDefinition, options) {
|
|
|
60
60
|
throw new Error('Bad query');
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
var definition = resolveToValue(queryDefinition);
|
|
64
63
|
var as = options.as,
|
|
65
64
|
_options$enabled = options.enabled,
|
|
66
|
-
enabled = _options$enabled === void 0 ? true : _options$enabled;
|
|
65
|
+
enabled = _options$enabled === void 0 ? true : _options$enabled; // If the query is not enabled, no need to call the queryDefinition
|
|
66
|
+
// because sometimes, we can have a getById(null) since we want to
|
|
67
|
+
// enabled the query only when the specific id is defined. And since
|
|
68
|
+
// Q() can throw error when some checks are KO we don't call Q() if
|
|
69
|
+
// enabled is not true
|
|
70
|
+
|
|
71
|
+
var definition = enabled ? resolveToValue(queryDefinition) : null;
|
|
67
72
|
|
|
68
73
|
if (!as) {
|
|
69
74
|
throw new Error('You must specify options.as when using useQuery');
|
|
@@ -8,6 +8,14 @@ import { Q } from '../queries/dsl'
|
|
|
8
8
|
import { setupClient, makeWrapper } from '../testing/utils'
|
|
9
9
|
import simpsonsFixture from '../testing/simpsons.json'
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* @param {object} Options options
|
|
13
|
+
* @param {object=} Options.customClient custom Client
|
|
14
|
+
* @param {object=} Options.queryDefinition custom Querydef
|
|
15
|
+
* @param {object=} Options.queryOptions custom QueryOpts
|
|
16
|
+
* @param {object=} Options.storeQueries custome StoreQueries
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
11
19
|
const setupQuery = ({
|
|
12
20
|
customClient,
|
|
13
21
|
queryDefinition,
|
|
@@ -51,7 +59,32 @@ describe('use query', () => {
|
|
|
51
59
|
})
|
|
52
60
|
})
|
|
53
61
|
})
|
|
54
|
-
|
|
62
|
+
it('should respect the enable property', () => {
|
|
63
|
+
const { client } = setupQuery({
|
|
64
|
+
queryOptions: {
|
|
65
|
+
as: 'simpsons',
|
|
66
|
+
enabled: false
|
|
67
|
+
},
|
|
68
|
+
queryDefinition: () => Q('io.cozy.simpsons')
|
|
69
|
+
})
|
|
70
|
+
expect(client.query).not.toHaveBeenCalled()
|
|
71
|
+
})
|
|
72
|
+
it('should respect not throw error if the qDef contains a getById with null', () => {
|
|
73
|
+
const {
|
|
74
|
+
client,
|
|
75
|
+
hookResult: {
|
|
76
|
+
result: { current }
|
|
77
|
+
}
|
|
78
|
+
} = setupQuery({
|
|
79
|
+
queryOptions: {
|
|
80
|
+
as: 'simpsonsTest',
|
|
81
|
+
enabled: false
|
|
82
|
+
},
|
|
83
|
+
queryDefinition: () => Q('io.cozy.simpsons').getById(null)
|
|
84
|
+
})
|
|
85
|
+
expect(client.query).not.toThrowError()
|
|
86
|
+
expect(current.fetchStatus).toEqual('pending')
|
|
87
|
+
})
|
|
55
88
|
it('should share the same API than ObservableQuery', () => {
|
|
56
89
|
const {
|
|
57
90
|
hookResult: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "34.6.
|
|
3
|
+
"version": "34.6.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
"react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
|
|
74
74
|
},
|
|
75
75
|
"sideEffects": false,
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "83651b3c5763b255b796d9dcdd037ed4527fb965"
|
|
77
77
|
}
|