cozy-client 51.3.0 → 51.4.0
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 +8 -14
- package/dist/Provider.spec.jsx +6 -6
- package/dist/Query.spec.jsx +29 -20
- package/dist/__tests__/setup.js +1 -9
- package/dist/hoc.spec.jsx +48 -58
- package/dist/hooks/useClient.spec.jsx +4 -3
- package/dist/withMutation.spec.jsx +14 -11
- package/dist/withMutations.spec.jsx +32 -21
- package/package.json +5 -4
package/dist/CozyClient.js
CHANGED
|
@@ -2607,32 +2607,26 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2607
2607
|
key: "loadInstanceOptionsFromStack",
|
|
2608
2608
|
value: function () {
|
|
2609
2609
|
var _loadInstanceOptionsFromStack = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
|
|
2610
|
-
var
|
|
2611
|
-
|
|
2610
|
+
var results, capabilitiesData, instanceData;
|
|
2612
2611
|
return _regenerator.default.wrap(function _callee20$(_context20) {
|
|
2613
2612
|
while (1) {
|
|
2614
2613
|
switch (_context20.prev = _context20.next) {
|
|
2615
2614
|
case 0:
|
|
2616
2615
|
_context20.next = 2;
|
|
2617
|
-
return this.query((0, _dsl.Q)('io.cozy.settings').getById('io.cozy.settings.capabilities'));
|
|
2616
|
+
return Promise.all([this.query((0, _dsl.Q)('io.cozy.settings').getById('io.cozy.settings.capabilities')), this.query((0, _dsl.Q)('io.cozy.settings').getById('io.cozy.settings.instance'))]);
|
|
2618
2617
|
|
|
2619
2618
|
case 2:
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
return this.query((0, _dsl.Q)('io.cozy.settings').getById('io.cozy.settings.instance'));
|
|
2624
|
-
|
|
2625
|
-
case 6:
|
|
2626
|
-
_yield$this$query2 = _context20.sent;
|
|
2627
|
-
instanceData = _yield$this$query2.data;
|
|
2619
|
+
results = _context20.sent;
|
|
2620
|
+
capabilitiesData = results[0].data;
|
|
2621
|
+
instanceData = results[1].data;
|
|
2628
2622
|
this.instanceOptions = {
|
|
2629
|
-
capabilities:
|
|
2623
|
+
capabilities: capabilitiesData,
|
|
2630
2624
|
locale: instanceData.locale,
|
|
2631
2625
|
tracking: instanceData.tracking
|
|
2632
2626
|
};
|
|
2633
2627
|
this.capabilities = this.instanceOptions.capabilities || null;
|
|
2634
2628
|
|
|
2635
|
-
case
|
|
2629
|
+
case 7:
|
|
2636
2630
|
case "end":
|
|
2637
2631
|
return _context20.stop();
|
|
2638
2632
|
}
|
|
@@ -3032,7 +3026,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
3032
3026
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
3033
3027
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
3034
3028
|
|
|
3035
|
-
CozyClient.version = "51.
|
|
3029
|
+
CozyClient.version = "51.4.0";
|
|
3036
3030
|
|
|
3037
3031
|
_microee.default.mixin(CozyClient);
|
|
3038
3032
|
|
package/dist/Provider.spec.jsx
CHANGED
|
@@ -3,7 +3,7 @@ jest.mock('./CozyClient')
|
|
|
3
3
|
import React, { Component } from 'react'
|
|
4
4
|
import PropTypes from 'prop-types'
|
|
5
5
|
import configureStore from 'redux-mock-store'
|
|
6
|
-
import {
|
|
6
|
+
import { fireEvent, render } from '@testing-library/react'
|
|
7
7
|
|
|
8
8
|
import Provider from './Provider'
|
|
9
9
|
import CozyClient from './CozyClient'
|
|
@@ -13,12 +13,12 @@ describe('Provider', () => {
|
|
|
13
13
|
const store = configureStore()({})
|
|
14
14
|
|
|
15
15
|
it('should renders children when passed in', () => {
|
|
16
|
-
const wrapper =
|
|
16
|
+
const wrapper = render(
|
|
17
17
|
<Provider client={client} store={store}>
|
|
18
|
-
<div
|
|
18
|
+
<div>Component</div>
|
|
19
19
|
</Provider>
|
|
20
20
|
)
|
|
21
|
-
expect(wrapper.
|
|
21
|
+
expect(wrapper.getByText('Component')).toBeTruthy()
|
|
22
22
|
})
|
|
23
23
|
|
|
24
24
|
it('should provide the client in the context', () => {
|
|
@@ -33,12 +33,12 @@ describe('Provider', () => {
|
|
|
33
33
|
return <button onClick={this.onClick} />
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
const wrapper =
|
|
36
|
+
const wrapper = render(
|
|
37
37
|
<Provider client={client} store={store}>
|
|
38
38
|
<FakeComponent />
|
|
39
39
|
</Provider>
|
|
40
40
|
)
|
|
41
|
-
wrapper.
|
|
41
|
+
fireEvent.click(wrapper.getByRole('button'))
|
|
42
42
|
expect(client.query).toHaveBeenCalledWith('foo')
|
|
43
43
|
})
|
|
44
44
|
})
|
package/dist/Query.spec.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { screen, render } from '@testing-library/react'
|
|
3
3
|
import CozyProvider from './Provider'
|
|
4
4
|
|
|
5
5
|
import Query from './Query'
|
|
@@ -34,17 +34,24 @@ describe('Query', () => {
|
|
|
34
34
|
|
|
35
35
|
describe('lifecycle', () => {
|
|
36
36
|
it('should fire a query fetch when mounted', () => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
render(
|
|
38
|
+
<CozyProvider client={client}>
|
|
39
|
+
<Query query={queryDef}>{() => null}</Query>
|
|
40
|
+
</CozyProvider>,
|
|
41
|
+
{
|
|
42
|
+
context
|
|
43
|
+
}
|
|
44
|
+
)
|
|
40
45
|
expect(observableQuery.fetch).toHaveBeenCalled()
|
|
41
46
|
})
|
|
42
47
|
|
|
43
48
|
it('should not fire a query fetch when mounted if enabled is set to false', () => {
|
|
44
|
-
|
|
45
|
-
<
|
|
46
|
-
{
|
|
47
|
-
|
|
49
|
+
render(
|
|
50
|
+
<CozyProvider client={client}>
|
|
51
|
+
<Query query={queryDef} enabled={false}>
|
|
52
|
+
{() => null}
|
|
53
|
+
</Query>
|
|
54
|
+
</CozyProvider>,
|
|
48
55
|
{
|
|
49
56
|
context
|
|
50
57
|
}
|
|
@@ -56,10 +63,12 @@ describe('Query', () => {
|
|
|
56
63
|
const queryState = { lastUpdate: Date.now() }
|
|
57
64
|
client.getQueryFromState = jest.fn().mockReturnValue(queryState)
|
|
58
65
|
const fetchPolicy = jest.fn().mockReturnValue(false)
|
|
59
|
-
|
|
60
|
-
<
|
|
61
|
-
{
|
|
62
|
-
|
|
66
|
+
render(
|
|
67
|
+
<CozyProvider client={client}>
|
|
68
|
+
<Query query={queryDef} as="allTodos" fetchPolicy={fetchPolicy}>
|
|
69
|
+
{() => null}
|
|
70
|
+
</Query>
|
|
71
|
+
</CozyProvider>,
|
|
63
72
|
{ context }
|
|
64
73
|
)
|
|
65
74
|
expect(client.getQueryFromState).toHaveBeenCalledWith('allTodos')
|
|
@@ -72,7 +81,7 @@ describe('Query', () => {
|
|
|
72
81
|
const store = assets.store
|
|
73
82
|
const client = assets.client
|
|
74
83
|
const spy = jest.spyOn(store, 'dispatch')
|
|
75
|
-
|
|
84
|
+
render(
|
|
76
85
|
<CozyProvider client={client}>
|
|
77
86
|
<Query query={queryDef}>{() => null}</Query>
|
|
78
87
|
</CozyProvider>
|
|
@@ -97,14 +106,14 @@ describe('Query', () => {
|
|
|
97
106
|
})
|
|
98
107
|
|
|
99
108
|
describe('data reactions', () => {
|
|
100
|
-
let store, client
|
|
109
|
+
let store, client
|
|
101
110
|
beforeEach(async () => {
|
|
102
111
|
const assets = createTestAssets()
|
|
103
112
|
store = assets.store
|
|
104
113
|
client = assets.client
|
|
105
114
|
const noFetch = () => false
|
|
106
115
|
await store.dispatch(initQuery('allTodos', queryDef(client)))
|
|
107
|
-
|
|
116
|
+
render(
|
|
108
117
|
<CozyProvider client={client}>
|
|
109
118
|
<Query fetchPolicy={noFetch} query={queryDef}>
|
|
110
119
|
{({ data }) => (
|
|
@@ -120,11 +129,11 @@ describe('Query', () => {
|
|
|
120
129
|
})
|
|
121
130
|
|
|
122
131
|
it('should be refreshed when relevant results are updated', async () => {
|
|
123
|
-
expect(
|
|
132
|
+
expect(screen.queryByText('Build stuff')).not.toBeInTheDocument()
|
|
124
133
|
const response = queryResultFromData(TODOS)
|
|
125
134
|
const action = receiveQueryResult('allTodos', response)
|
|
126
135
|
await store.dispatch(action)
|
|
127
|
-
expect(
|
|
136
|
+
expect(screen.queryByText('Build stuff')).toBeInTheDocument()
|
|
128
137
|
})
|
|
129
138
|
|
|
130
139
|
it('should refresh queries concerned by a REMOVE_REFERENCE_TO mutation', async () => {
|
|
@@ -166,7 +175,7 @@ describe('Query', () => {
|
|
|
166
175
|
|
|
167
176
|
const setup = ({ children }) => {
|
|
168
177
|
const noFetch = () => false
|
|
169
|
-
|
|
178
|
+
render(
|
|
170
179
|
<CozyProvider client={client}>
|
|
171
180
|
<Query fetchPolicy={noFetch} query={queryDef}>
|
|
172
181
|
{children}
|
|
@@ -239,7 +248,7 @@ describe('Query', () => {
|
|
|
239
248
|
|
|
240
249
|
const noFetch = () => false
|
|
241
250
|
|
|
242
|
-
|
|
251
|
+
render(
|
|
243
252
|
<CozyProvider client={client}>
|
|
244
253
|
<Query fetchPolicy={noFetch} query={queryDef} mutations={mutations}>
|
|
245
254
|
{(result, mutations) => {
|
|
@@ -269,7 +278,7 @@ describe('Query', () => {
|
|
|
269
278
|
|
|
270
279
|
const noFetch = () => false
|
|
271
280
|
|
|
272
|
-
|
|
281
|
+
render(
|
|
273
282
|
<CozyProvider client={client}>
|
|
274
283
|
<Query fetchPolicy={noFetch} query={queryDef} mutations={mutations}>
|
|
275
284
|
{(result, mutations) => {
|
package/dist/__tests__/setup.js
CHANGED
|
@@ -2,14 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
var _enzyme = _interopRequireDefault(require("enzyme"));
|
|
6
|
-
|
|
7
|
-
var _enzymeAdapterReact = _interopRequireDefault(require("enzyme-adapter-react-16"));
|
|
8
|
-
|
|
9
5
|
var _whatwgFetch = _interopRequireDefault(require("whatwg-fetch"));
|
|
10
6
|
|
|
11
|
-
global.fetch = _whatwgFetch.default;
|
|
12
|
-
|
|
13
|
-
_enzyme.default.configure({
|
|
14
|
-
adapter: new _enzymeAdapterReact.default()
|
|
15
|
-
});
|
|
7
|
+
global.fetch = _whatwgFetch.default;
|
package/dist/hoc.spec.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
2
|
import { Provider as ReduxProvider } from 'react-redux'
|
|
3
|
-
import {
|
|
3
|
+
import { fireEvent, render, screen } from '@testing-library/react'
|
|
4
4
|
|
|
5
5
|
import { withClient, queryConnect, queryConnectFlat } from './hoc'
|
|
6
6
|
import { Q } from './queries/dsl'
|
|
@@ -12,17 +12,15 @@ import { setupClient } from './testing/utils'
|
|
|
12
12
|
|
|
13
13
|
beforeEach(() => {
|
|
14
14
|
jest.spyOn(logger, 'warn').mockImplementation(() => {})
|
|
15
|
+
Component.mockClear()
|
|
15
16
|
})
|
|
16
17
|
|
|
17
18
|
afterEach(() => {
|
|
18
19
|
logger.warn.mockRestore()
|
|
19
20
|
})
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return <div />
|
|
24
|
-
}
|
|
25
|
-
}
|
|
22
|
+
const Component = jest.fn(() => <div>Component</div>)
|
|
23
|
+
Component.displayName = 'Component'
|
|
26
24
|
|
|
27
25
|
describe('with client', () => {
|
|
28
26
|
it('should give a display name', () => {
|
|
@@ -38,12 +36,13 @@ describe('with client', () => {
|
|
|
38
36
|
getState: jest.fn()
|
|
39
37
|
}
|
|
40
38
|
const WithClientComponent = withClient(Component)
|
|
41
|
-
|
|
39
|
+
render(
|
|
42
40
|
<Provider client={client} store={store}>
|
|
43
41
|
<WithClientComponent />
|
|
44
42
|
</Provider>
|
|
45
43
|
)
|
|
46
|
-
|
|
44
|
+
|
|
45
|
+
expect(Component).toHaveBeenCalledWith({ client }, {})
|
|
47
46
|
})
|
|
48
47
|
})
|
|
49
48
|
|
|
@@ -75,19 +74,23 @@ describe('queryConnect', () => {
|
|
|
75
74
|
const context = {
|
|
76
75
|
client
|
|
77
76
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
77
|
+
render(
|
|
78
|
+
<Provider client={client}>
|
|
79
|
+
<WithQueries />
|
|
80
|
+
</Provider>,
|
|
81
|
+
{ context }
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
const propsPassedToComponent = Component.mock.calls[0][0]
|
|
85
|
+
|
|
86
|
+
expect(propsPassedToComponent.simpsons.data.map(x => x.name)).toEqual([
|
|
87
|
+
'Homer',
|
|
88
|
+
'Marge'
|
|
89
|
+
])
|
|
90
|
+
expect(propsPassedToComponent.upperSimpsons.data.map(x => x.name)).toEqual([
|
|
91
|
+
'HOMER',
|
|
92
|
+
'MARGE'
|
|
93
|
+
])
|
|
91
94
|
})
|
|
92
95
|
|
|
93
96
|
it('should be possible to pass props', () => {
|
|
@@ -109,20 +112,23 @@ describe('queryConnect', () => {
|
|
|
109
112
|
</Provider>
|
|
110
113
|
)
|
|
111
114
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
|
|
116
|
+
render(<Wrapper client={client} />)
|
|
117
|
+
|
|
118
|
+
expect(Component).toHaveBeenCalledWith(
|
|
115
119
|
expect.objectContaining({
|
|
116
|
-
|
|
117
|
-
})
|
|
120
|
+
simpsonId: 'marge'
|
|
121
|
+
}),
|
|
122
|
+
{}
|
|
118
123
|
)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
expect(
|
|
124
|
+
|
|
125
|
+
fireEvent.click(screen.getByText('change to homer'))
|
|
126
|
+
|
|
127
|
+
expect(Component).toHaveBeenCalledWith(
|
|
123
128
|
expect.objectContaining({
|
|
124
|
-
|
|
125
|
-
})
|
|
129
|
+
simpsonId: 'homer'
|
|
130
|
+
}),
|
|
131
|
+
{}
|
|
126
132
|
)
|
|
127
133
|
})
|
|
128
134
|
})
|
|
@@ -144,38 +150,22 @@ describe('queryConnectFlat', () => {
|
|
|
144
150
|
|
|
145
151
|
it('should pass result of query definitions as props', () => {
|
|
146
152
|
const { WithQueries, client } = setup()
|
|
147
|
-
|
|
153
|
+
render(
|
|
148
154
|
<ReduxProvider store={client.store}>
|
|
149
155
|
<Provider client={client}>
|
|
150
156
|
<WithQueries />
|
|
151
157
|
</Provider>
|
|
152
158
|
</ReduxProvider>
|
|
153
159
|
)
|
|
154
|
-
|
|
155
|
-
uut
|
|
156
|
-
.find(Component)
|
|
157
|
-
.prop('simpsons')
|
|
158
|
-
.data.map(x => x.name)
|
|
159
|
-
).toEqual(['Homer', 'Marge'])
|
|
160
|
-
expect(
|
|
161
|
-
uut
|
|
162
|
-
.find(Component)
|
|
163
|
-
.prop('upperSimpsons')
|
|
164
|
-
.data.map(x => x.name)
|
|
165
|
-
).toEqual(['HOMER', 'MARGE'])
|
|
166
|
-
})
|
|
160
|
+
const propsPassedToComponent = Component.mock.calls[0][0]
|
|
167
161
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
)
|
|
177
|
-
const queryConnectFlatComponent = uut.find('queryConnectFlat(Component)')
|
|
178
|
-
expect(queryConnectFlatComponent.length).toBe(1)
|
|
179
|
-
expect(queryConnectFlatComponent.children().is('Component')).toBe(true)
|
|
162
|
+
expect(propsPassedToComponent.simpsons.data.map(x => x.name)).toEqual([
|
|
163
|
+
'Homer',
|
|
164
|
+
'Marge'
|
|
165
|
+
])
|
|
166
|
+
expect(propsPassedToComponent.upperSimpsons.data.map(x => x.name)).toEqual([
|
|
167
|
+
'HOMER',
|
|
168
|
+
'MARGE'
|
|
169
|
+
])
|
|
180
170
|
})
|
|
181
171
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import useClient from './useClient'
|
|
3
3
|
import Provider from '../Provider'
|
|
4
|
-
import {
|
|
4
|
+
import { screen, render } from '@testing-library/react'
|
|
5
5
|
|
|
6
6
|
describe('useClient', () => {
|
|
7
7
|
const Component = () => {
|
|
@@ -10,11 +10,12 @@ describe('useClient', () => {
|
|
|
10
10
|
}
|
|
11
11
|
it('should get the client from the nearest Provider', () => {
|
|
12
12
|
const client = { stackClient: { uri: 'https://test.mycozy.cloud' } }
|
|
13
|
-
|
|
13
|
+
render(
|
|
14
14
|
<Provider client={client}>
|
|
15
15
|
<Component />
|
|
16
16
|
</Provider>
|
|
17
17
|
)
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
screen.getByText('https://test.mycozy.cloud')
|
|
19
20
|
})
|
|
20
21
|
})
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { fireEvent, render } from '@testing-library/react'
|
|
3
3
|
|
|
4
4
|
import CozyClient from './CozyClient'
|
|
5
5
|
import CozyLink from './CozyLink'
|
|
6
6
|
import withMutation from './withMutation'
|
|
7
|
+
import Provider from './Provider'
|
|
7
8
|
|
|
8
9
|
describe('withMutation', () => {
|
|
9
10
|
const NEW_TODO = {
|
|
@@ -25,11 +26,12 @@ describe('withMutation', () => {
|
|
|
25
26
|
)
|
|
26
27
|
const ConnectedAddButton = withMutation(mutationCreator)(AddButton)
|
|
27
28
|
|
|
28
|
-
const wrapper =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const wrapper = render(
|
|
30
|
+
<Provider client={client}>
|
|
31
|
+
<ConnectedAddButton />
|
|
32
|
+
</Provider>
|
|
33
|
+
)
|
|
34
|
+
fireEvent.click(wrapper.getByRole('button'))
|
|
33
35
|
|
|
34
36
|
expect(mutationCreator).toHaveBeenCalledWith(NEW_TODO)
|
|
35
37
|
})
|
|
@@ -42,11 +44,12 @@ describe('withMutation', () => {
|
|
|
42
44
|
name: 'addTodo'
|
|
43
45
|
})(AddButton)
|
|
44
46
|
|
|
45
|
-
const wrapper =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
const wrapper = render(
|
|
48
|
+
<Provider client={client}>
|
|
49
|
+
<ConnectedAddButton />
|
|
50
|
+
</Provider>
|
|
51
|
+
)
|
|
52
|
+
fireEvent.click(wrapper.getByRole('button'))
|
|
50
53
|
|
|
51
54
|
expect(mutationCreator).toHaveBeenCalledWith(NEW_TODO)
|
|
52
55
|
})
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import {
|
|
2
|
+
import { render } from '@testing-library/react'
|
|
3
3
|
|
|
4
4
|
import withMutations from './withMutations'
|
|
5
|
+
import Provider from './Provider'
|
|
5
6
|
|
|
6
7
|
describe('withMutations', () => {
|
|
7
8
|
beforeEach(() => {
|
|
@@ -49,21 +50,29 @@ describe('withMutations', () => {
|
|
|
49
50
|
|
|
50
51
|
expect(() => {
|
|
51
52
|
const ConnectedFoo = withMutations(mutationsMock)(Foo)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
render(
|
|
54
|
+
<Provider client={clientMock}>
|
|
55
|
+
<ConnectedFoo />
|
|
56
|
+
</Provider>
|
|
57
|
+
)
|
|
55
58
|
}).not.toThrowError()
|
|
56
59
|
})
|
|
57
60
|
|
|
58
61
|
it('should inject base mutations props into wrapped component', async () => {
|
|
59
|
-
const Foo = () => <div
|
|
62
|
+
const Foo = jest.fn(() => <div>Component</div>)
|
|
60
63
|
const ConnectedFoo = withMutations()(Foo)
|
|
61
64
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
render(
|
|
66
|
+
<Provider client={clientMock}>
|
|
67
|
+
<ConnectedFoo />
|
|
68
|
+
</Provider>
|
|
69
|
+
)
|
|
65
70
|
|
|
66
|
-
const {
|
|
71
|
+
const {
|
|
72
|
+
createDocument,
|
|
73
|
+
saveDocument,
|
|
74
|
+
deleteDocument
|
|
75
|
+
} = Foo.mock.calls[0][0]
|
|
67
76
|
|
|
68
77
|
expect(typeof createDocument).toBe('function')
|
|
69
78
|
expect(typeof saveDocument).toBe('function')
|
|
@@ -71,17 +80,18 @@ describe('withMutations', () => {
|
|
|
71
80
|
})
|
|
72
81
|
|
|
73
82
|
it('should inject mutations props from one source into wrapped component', async () => {
|
|
74
|
-
const Foo = () => <div
|
|
75
|
-
|
|
83
|
+
const Foo = jest.fn(() => <div>Component</div>)
|
|
76
84
|
const ConnectedFoo = withMutations(client => ({
|
|
77
85
|
mutate: client => client.mutate()
|
|
78
86
|
}))(Foo)
|
|
79
87
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
88
|
+
render(
|
|
89
|
+
<Provider client={clientMock}>
|
|
90
|
+
<ConnectedFoo />
|
|
91
|
+
</Provider>
|
|
92
|
+
)
|
|
83
93
|
|
|
84
|
-
const { mutate } =
|
|
94
|
+
const { mutate } = Foo.mock.calls[0][0]
|
|
85
95
|
expect(typeof mutate).toBe('function')
|
|
86
96
|
|
|
87
97
|
mutate(clientMock)
|
|
@@ -89,8 +99,7 @@ describe('withMutations', () => {
|
|
|
89
99
|
})
|
|
90
100
|
|
|
91
101
|
it('should inject mutations props from several sources into wrapped component', async () => {
|
|
92
|
-
const Foo = () => <div
|
|
93
|
-
|
|
102
|
+
const Foo = jest.fn(() => <div>Component</div>)
|
|
94
103
|
const mutations = client => ({
|
|
95
104
|
mutate: client => client.mutate()
|
|
96
105
|
})
|
|
@@ -101,11 +110,13 @@ describe('withMutations', () => {
|
|
|
101
110
|
|
|
102
111
|
const ConnectedFoo = withMutations(mutations, anotherMutations)(Foo)
|
|
103
112
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
113
|
+
render(
|
|
114
|
+
<Provider client={clientMock}>
|
|
115
|
+
<ConnectedFoo />
|
|
116
|
+
</Provider>
|
|
117
|
+
)
|
|
107
118
|
|
|
108
|
-
const { mutate, mutateAsWell } =
|
|
119
|
+
const { mutate, mutateAsWell } = Foo.mock.calls[0][0]
|
|
109
120
|
|
|
110
121
|
expect(typeof mutate).toBe('function')
|
|
111
122
|
expect(typeof mutateAsWell).toBe('function')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "51.
|
|
3
|
+
"version": "51.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -43,8 +43,9 @@
|
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@babel/cli": "7.12.8",
|
|
45
45
|
"@cozy/codemods": "1.14.4",
|
|
46
|
-
"@testing-library/
|
|
47
|
-
"@testing-library/react
|
|
46
|
+
"@testing-library/jest-dom": "6.6.3",
|
|
47
|
+
"@testing-library/react": "12.1.5",
|
|
48
|
+
"@testing-library/react-hooks": "7.0.2",
|
|
48
49
|
"babel-plugin-search-and-replace": "1.1.1",
|
|
49
50
|
"btoa": "1.2.1",
|
|
50
51
|
"cozy-device-helper": "2.7.0",
|
|
@@ -71,5 +72,5 @@
|
|
|
71
72
|
"react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
|
|
72
73
|
},
|
|
73
74
|
"sideEffects": false,
|
|
74
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "f13f75f38ad792fef00b574c27d46a99c0c294a2"
|
|
75
76
|
}
|