@dhis2/app-service-data 3.2.7 → 3.3.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.
@@ -2,79 +2,347 @@
2
2
 
3
3
  var _reactHooks = require("@testing-library/react-hooks");
4
4
 
5
- var _react = _interopRequireDefault(require("react"));
5
+ var React = _interopRequireWildcard(require("react"));
6
6
 
7
7
  var _CustomDataProvider = require("../components/CustomDataProvider");
8
8
 
9
+ var _useDataEngine = require("./useDataEngine");
10
+
9
11
  var _useDataMutation = require("./useDataMutation");
10
12
 
11
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
-
13
- const customData = {
14
- answer: 42
15
- };
16
-
17
- const wrapper = ({
18
- children
19
- }) => /*#__PURE__*/_react.default.createElement(_CustomDataProvider.CustomDataProvider, {
20
- data: customData
21
- }, children);
22
-
23
- const mutation = {
24
- type: 'create',
25
- resource: 'answer',
26
- data: {
27
- answer: 42
28
- }
29
- };
30
- describe('useDataMustation', () => {
31
- const originalError = console.error;
32
- afterEach(() => {
33
- console.error = originalError;
13
+ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
14
+
15
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
+
17
+ describe('useDataMutation', () => {
18
+ it('should render without failing', async () => {
19
+ const mutation = {
20
+ type: 'create',
21
+ resource: 'answer',
22
+ data: {
23
+ answer: '?'
24
+ }
25
+ };
26
+ const data = {
27
+ answer: 42
28
+ };
29
+
30
+ const wrapper = ({
31
+ children
32
+ }) => /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
33
+ data: data
34
+ }, children);
35
+
36
+ const {
37
+ result,
38
+ waitFor
39
+ } = (0, _reactHooks.renderHook)(() => (0, _useDataMutation.useDataMutation)(mutation), {
40
+ wrapper
41
+ });
42
+ const [mutate, beforeMutation] = result.current;
43
+ expect(beforeMutation).toMatchObject({
44
+ loading: false,
45
+ called: false
46
+ });
47
+ (0, _reactHooks.act)(() => {
48
+ mutate();
49
+ });
50
+ await waitFor(() => {
51
+ const [, duringMutation] = result.current;
52
+ expect(duringMutation).toMatchObject({
53
+ loading: true,
54
+ called: true
55
+ });
56
+ });
57
+ await waitFor(() => {
58
+ const [, afterMutation] = result.current;
59
+ expect(afterMutation).toMatchObject({
60
+ loading: false,
61
+ called: true,
62
+ data: 42
63
+ });
64
+ });
34
65
  });
35
- it('Should render without failing', async () => {
36
- let hookState;
37
- console.error = jest.fn();
66
+ it('should run immediately with lazy: false', async () => {
67
+ const mutation = {
68
+ type: 'create',
69
+ resource: 'answer',
70
+ data: {
71
+ answer: '?'
72
+ }
73
+ };
74
+ const data = {
75
+ answer: 42
76
+ };
77
+
78
+ const wrapper = ({
79
+ children
80
+ }) => /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
81
+ data: data
82
+ }, children);
83
+
84
+ const {
85
+ result,
86
+ waitFor
87
+ } = (0, _reactHooks.renderHook)(() => (0, _useDataMutation.useDataMutation)(mutation, {
88
+ lazy: false
89
+ }), {
90
+ wrapper
91
+ });
92
+ const [, duringMutation] = result.current;
93
+ expect(duringMutation).toMatchObject({
94
+ loading: true,
95
+ called: true
96
+ });
97
+ await waitFor(() => {
98
+ const [, afterMutation] = result.current;
99
+ expect(afterMutation).toMatchObject({
100
+ loading: false,
101
+ called: true,
102
+ data: 42
103
+ });
104
+ });
105
+ });
106
+ it('should call onComplete on success', async () => {
107
+ const onComplete = jest.fn();
108
+ const mutation = {
109
+ type: 'create',
110
+ resource: 'answer',
111
+ data: {
112
+ answer: '?'
113
+ }
114
+ };
115
+ const data = {
116
+ answer: 42
117
+ };
118
+
119
+ const wrapper = ({
120
+ children
121
+ }) => /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
122
+ data: data
123
+ }, children);
124
+
125
+ const {
126
+ result,
127
+ waitFor
128
+ } = (0, _reactHooks.renderHook)(() => (0, _useDataMutation.useDataMutation)(mutation, {
129
+ onComplete
130
+ }), {
131
+ wrapper
132
+ });
133
+ expect(onComplete).toHaveBeenCalledTimes(0);
134
+ const [mutate] = result.current;
38
135
  (0, _reactHooks.act)(() => {
39
- hookState = (0, _reactHooks.renderHook)(() => (0, _useDataMutation.useDataMutation)(mutation), {
40
- wrapper
136
+ mutate();
137
+ });
138
+ await waitFor(() => {
139
+ const [, state] = result.current;
140
+ expect(state).toMatchObject({
141
+ loading: false,
142
+ called: true,
143
+ data: 42
41
144
  });
145
+ expect(onComplete).toHaveBeenCalledTimes(1);
146
+ expect(onComplete).toHaveBeenLastCalledWith(42);
42
147
  });
43
- let [mutate, state] = hookState.result.current;
44
- expect(state).toMatchObject({
45
- called: false,
46
- loading: false
148
+ });
149
+ it('should call onError on error', async () => {
150
+ const error = new Error('Something went wrong');
151
+ const onError = jest.fn();
152
+ const mutation = {
153
+ type: 'create',
154
+ resource: 'answer',
155
+ data: {
156
+ answer: 42
157
+ }
158
+ };
159
+ const data = {
160
+ answer: () => {
161
+ throw error;
162
+ }
163
+ };
164
+
165
+ const wrapper = ({
166
+ children
167
+ }) => /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
168
+ data: data
169
+ }, children);
170
+
171
+ const {
172
+ result,
173
+ waitFor
174
+ } = (0, _reactHooks.renderHook)(() => (0, _useDataMutation.useDataMutation)(mutation, {
175
+ onError
176
+ }), {
177
+ wrapper
47
178
  });
179
+ expect(onError).toHaveBeenCalledTimes(0);
180
+ const [mutate] = result.current;
48
181
  (0, _reactHooks.act)(() => {
49
182
  mutate();
50
183
  });
51
- mutate = hookState.result.current[0];
52
- state = hookState.result.current[1];
53
- expect(state).toMatchObject({
54
- called: true,
55
- loading: true
184
+ await waitFor(() => {
185
+ const [, state] = result.current;
186
+ expect(state).toMatchObject({
187
+ loading: false,
188
+ called: true,
189
+ error
190
+ });
56
191
  });
192
+ expect(onError).toHaveBeenCalledTimes(1);
193
+ expect(onError).toHaveBeenLastCalledWith(error);
57
194
  });
58
- it('Should run immediately with lazy: false', async () => {
59
- let hookState;
60
- console.error = jest.fn();
195
+ it('should resolve variables', async () => {
196
+ const mutation = {
197
+ type: 'update',
198
+ resource: 'answer',
199
+ id: ({
200
+ id
201
+ }) => id,
202
+ data: {
203
+ answer: '?'
204
+ }
205
+ };
206
+ const answerSpy = jest.fn(() => 42);
207
+ const data = {
208
+ answer: answerSpy
209
+ };
210
+
211
+ const wrapper = ({
212
+ children
213
+ }) => /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
214
+ data: data
215
+ }, children);
216
+
217
+ const {
218
+ result,
219
+ waitFor
220
+ } = (0, _reactHooks.renderHook)(() => (0, _useDataMutation.useDataMutation)(mutation, {
221
+ lazy: false,
222
+ variables: {
223
+ id: '1'
224
+ }
225
+ }), {
226
+ wrapper
227
+ });
228
+ await waitFor(() => {
229
+ expect(answerSpy).toHaveBeenLastCalledWith(expect.any(String), expect.objectContaining({
230
+ id: '1'
231
+ }), expect.any(Object));
232
+ });
233
+ const [mutate] = result.current;
61
234
  (0, _reactHooks.act)(() => {
62
- hookState = (0, _reactHooks.renderHook)(() => (0, _useDataMutation.useDataMutation)(mutation, {
63
- lazy: false
64
- }), {
65
- wrapper
235
+ mutate({
236
+ id: '2'
66
237
  });
67
238
  });
68
- let [, state] = hookState.result.current;
69
- expect(state).toMatchObject({
70
- called: true,
71
- loading: true
239
+ await waitFor(() => {
240
+ expect(answerSpy).toHaveBeenLastCalledWith(expect.any(String), expect.objectContaining({
241
+ id: '2'
242
+ }), expect.any(Object));
72
243
  });
73
- await hookState.waitForNextUpdate();
74
- state = hookState.result.current[1];
244
+ });
245
+ it('should return a reference to the engine', async () => {
246
+ const mutation = {
247
+ type: 'create',
248
+ resource: 'answer',
249
+ data: {
250
+ answer: '?'
251
+ }
252
+ };
253
+
254
+ const wrapper = ({
255
+ children
256
+ }) => /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
257
+ data: {}
258
+ }, children);
259
+
260
+ const engineHook = (0, _reactHooks.renderHook)(() => (0, _useDataEngine.useDataEngine)(), {
261
+ wrapper
262
+ });
263
+ const mutationHook = (0, _reactHooks.renderHook)(() => (0, _useDataMutation.useDataMutation)(mutation), {
264
+ wrapper
265
+ });
266
+ /**
267
+ * Ideally we'd check referential equality here with .toBe, but since
268
+ * both hooks run in a different context that doesn't work.
269
+ */
270
+
271
+ expect(mutationHook.result.current[1].engine).toStrictEqual(engineHook.result.current);
272
+ });
273
+ it('should return a stable mutate function', async () => {
274
+ const mutation = {
275
+ type: 'create',
276
+ resource: 'answer',
277
+ data: {
278
+ answer: '?'
279
+ }
280
+ };
281
+ const data = {
282
+ answer: 42
283
+ };
284
+
285
+ const wrapper = ({
286
+ children
287
+ }) => /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
288
+ data: data
289
+ }, children);
290
+
291
+ const {
292
+ result
293
+ } = (0, _reactHooks.renderHook)(() => (0, _useDataMutation.useDataMutation)(mutation), {
294
+ wrapper
295
+ });
296
+ const [firstMutate] = result.current;
297
+ await (0, _reactHooks.act)(async () => {
298
+ await firstMutate({
299
+ variable: 'variable'
300
+ });
301
+ });
302
+ const [secondMutate, state] = result.current;
75
303
  expect(state).toMatchObject({
76
304
  loading: false,
77
- data: 42
305
+ called: true
306
+ });
307
+ expect(firstMutate).toBe(secondMutate);
308
+ });
309
+ it('should resolve with the data from mutate on success', async () => {
310
+ const mutation = {
311
+ type: 'create',
312
+ resource: 'answer',
313
+ data: {
314
+ answer: '?'
315
+ }
316
+ };
317
+ const data = {
318
+ answer: 42
319
+ };
320
+
321
+ const wrapper = ({
322
+ children
323
+ }) => /*#__PURE__*/React.createElement(_CustomDataProvider.CustomDataProvider, {
324
+ data: data
325
+ }, children);
326
+
327
+ const {
328
+ result,
329
+ waitFor
330
+ } = (0, _reactHooks.renderHook)(() => (0, _useDataMutation.useDataMutation)(mutation), {
331
+ wrapper
332
+ });
333
+ let mutatePromise;
334
+ const [mutate] = result.current;
335
+ (0, _reactHooks.act)(() => {
336
+ mutatePromise = mutate();
337
+ });
338
+ await waitFor(() => {
339
+ const [, state] = result.current;
340
+ expect(state).toMatchObject({
341
+ loading: false,
342
+ called: true,
343
+ data: 42
344
+ });
345
+ expect(mutatePromise).resolves.toBe(42);
78
346
  });
79
347
  });
80
348
  });
@@ -1,8 +1,8 @@
1
1
  import { render, waitFor } from '@testing-library/react';
2
2
  import * as React from 'react';
3
3
  import { CustomDataProvider, DataQuery } from '../react';
4
- describe('Testing custom data provider and useQuery hook', () => {
5
- it('Should render without failing', async () => {
4
+ describe('<DataQuery />', () => {
5
+ it('should render without failing', async () => {
6
6
  const data = {
7
7
  answer: 42
8
8
  };
@@ -13,18 +13,8 @@ describe('Testing custom data provider and useQuery hook', () => {
13
13
  data: data
14
14
  }, children);
15
15
 
16
- const renderFunction = jest.fn(({
17
- loading,
18
- error,
19
- data
20
- }) => {
21
- if (loading) return 'loading';
22
- if (error) return /*#__PURE__*/React.createElement("div", null, "error: ", error.message);
23
- return /*#__PURE__*/React.createElement("div", null, "data: ", data && data.answer);
24
- });
25
- const {
26
- getByText
27
- } = render( /*#__PURE__*/React.createElement(DataQuery, {
16
+ const renderFunction = jest.fn(() => null);
17
+ render( /*#__PURE__*/React.createElement(DataQuery, {
28
18
  query: {
29
19
  answer: {
30
20
  resource: 'answer'
@@ -33,24 +23,21 @@ describe('Testing custom data provider and useQuery hook', () => {
33
23
  }, renderFunction), {
34
24
  wrapper
35
25
  });
36
- expect(getByText(/loading/i)).not.toBeUndefined();
37
26
  expect(renderFunction).toHaveBeenCalledTimes(1);
38
27
  expect(renderFunction).toHaveBeenLastCalledWith(expect.objectContaining({
39
28
  called: true,
40
29
  loading: true
41
30
  }));
42
31
  await waitFor(() => {
43
- getByText(/data: /i);
32
+ expect(renderFunction).toHaveBeenCalledTimes(2);
33
+ expect(renderFunction).toHaveBeenLastCalledWith(expect.objectContaining({
34
+ called: true,
35
+ loading: false,
36
+ data
37
+ }));
44
38
  });
45
- expect(getByText(/data: /i)).toHaveTextContent("data: ".concat(data.answer));
46
- expect(renderFunction).toHaveBeenCalledTimes(2);
47
- expect(renderFunction).toHaveBeenLastCalledWith(expect.objectContaining({
48
- called: true,
49
- loading: false,
50
- data
51
- }));
52
39
  });
53
- it('Should render an error', async () => {
40
+ it('should render an error', async () => {
54
41
  const expectedError = new Error('Something went wrong');
55
42
  const data = {
56
43
  test: () => {
@@ -64,18 +51,8 @@ describe('Testing custom data provider and useQuery hook', () => {
64
51
  data: data
65
52
  }, children);
66
53
 
67
- const renderFunction = jest.fn(({
68
- loading,
69
- error,
70
- data
71
- }) => {
72
- if (loading) return 'loading';
73
- if (error) return /*#__PURE__*/React.createElement("div", null, "error: ", error.message);
74
- return /*#__PURE__*/React.createElement("div", null, "data: ", data && data.test);
75
- });
76
- const {
77
- getByText
78
- } = render( /*#__PURE__*/React.createElement(DataQuery, {
54
+ const renderFunction = jest.fn(() => null);
55
+ render( /*#__PURE__*/React.createElement(DataQuery, {
79
56
  query: {
80
57
  test: {
81
58
  resource: 'test'
@@ -84,21 +61,18 @@ describe('Testing custom data provider and useQuery hook', () => {
84
61
  }, renderFunction), {
85
62
  wrapper
86
63
  });
87
- expect(getByText(/loading/i)).not.toBeUndefined();
88
64
  expect(renderFunction).toHaveBeenCalledTimes(1);
89
65
  expect(renderFunction).toHaveBeenLastCalledWith(expect.objectContaining({
90
66
  called: true,
91
67
  loading: true
92
68
  }));
93
69
  await waitFor(() => {
94
- getByText(/error: /i);
70
+ expect(renderFunction).toHaveBeenCalledTimes(2);
71
+ expect(renderFunction).toHaveBeenLastCalledWith(expect.objectContaining({
72
+ called: true,
73
+ loading: false,
74
+ error: expectedError
75
+ }));
95
76
  });
96
- expect(renderFunction).toHaveBeenCalledTimes(2);
97
- expect(getByText(/error: /i)).toHaveTextContent("error: ".concat(expectedError.message));
98
- expect(renderFunction).toHaveBeenLastCalledWith(expect.objectContaining({
99
- called: true,
100
- loading: false,
101
- error: expectedError
102
- }));
103
77
  });
104
78
  });
@@ -1,76 +1,65 @@
1
- import { render, act, waitFor } from '@testing-library/react';
2
- import React from 'react';
1
+ import { render, waitFor, act } from '@testing-library/react';
2
+ import * as React from 'react';
3
3
  import { CustomDataProvider, DataMutation } from '../react';
4
- const mockBackend = {
5
- target: jest.fn((type, query) => {
6
- expect(query.resource).toBe('target');
7
- expect(type).toBe('create');
8
- expect(query.data).toMatchObject({
9
- question: '?'
10
- });
11
- return Promise.resolve({
12
- answer: 42
13
- });
14
- })
15
- };
16
- describe('Test mutations', () => {
17
- it('Should call the mock callback', async () => {
18
- let doMutation;
19
- const renderFunction = jest.fn(([mutate, {
20
- called,
21
- loading,
22
- error,
23
- data
24
- }]) => {
25
- doMutation = mutate;
26
- if (!called) return 'uncalled';
27
- if (loading) return 'loading';
28
- if (error) return /*#__PURE__*/React.createElement("div", null, "error: ", error.message);
29
- if (data) return /*#__PURE__*/React.createElement("div", null, "data: ", data.answer);
30
- });
31
- const testMutation = {
32
- resource: 'target',
4
+ describe('<DataMutation />', () => {
5
+ it('should render without failing', async () => {
6
+ const endpointSpy = jest.fn(() => Promise.resolve(42));
7
+ const mutation = {
8
+ resource: 'answer',
33
9
  type: 'create',
34
10
  data: {
35
11
  question: '?'
36
12
  }
37
13
  };
38
- const {
39
- getByText
40
- } = render( /*#__PURE__*/React.createElement(CustomDataProvider, {
41
- data: mockBackend
42
- }, /*#__PURE__*/React.createElement(DataMutation, {
43
- mutation: testMutation
44
- }, renderFunction)));
45
- expect(getByText(/uncalled/i)).not.toBeUndefined();
46
- expect(renderFunction).toHaveBeenCalledTimes(1);
47
- expect(mockBackend.target).not.toHaveBeenCalled();
48
- expect(renderFunction).toHaveBeenLastCalledWith([expect.any(Function), {
14
+ const data = {
15
+ answer: endpointSpy
16
+ };
17
+
18
+ const wrapper = ({
19
+ children
20
+ }) => /*#__PURE__*/React.createElement(CustomDataProvider, {
21
+ data: data
22
+ }, children);
23
+
24
+ const renderSpy = jest.fn(() => null);
25
+ render( /*#__PURE__*/React.createElement(DataMutation, {
26
+ mutation: mutation
27
+ }, renderSpy), {
28
+ wrapper
29
+ });
30
+ expect(endpointSpy).toHaveBeenCalledTimes(0);
31
+ expect(renderSpy).toHaveBeenCalledTimes(1);
32
+ expect(renderSpy).toHaveBeenLastCalledWith([expect.any(Function), expect.objectContaining({
49
33
  called: false,
50
34
  loading: false,
51
35
  engine: expect.any(Object)
52
- }]);
53
- expect(doMutation).not.toBeUndefined();
54
- act(() => {
55
- doMutation && doMutation();
36
+ })]);
37
+ await act(async () => {
38
+ const firstRenderSpyCall = renderSpy.mock.calls[0];
39
+ const firstRenderSpyArgument = firstRenderSpyCall[0];
40
+ const [mutate] = firstRenderSpyArgument;
41
+ await mutate();
42
+ });
43
+ waitFor(() => {
44
+ expect(endpointSpy).toHaveBeenCalledTimes(1);
45
+ expect(renderSpy).toHaveBeenCalledTimes(2);
46
+ expect(renderSpy).toHaveBeenLastCalledWith([expect.any(Function), expect.objectContaining({
47
+ called: true,
48
+ loading: true,
49
+ engine: expect.any(Object)
50
+ })]);
51
+ });
52
+ waitFor(() => {
53
+ expect(endpointSpy).toHaveBeenCalledTimes(1);
54
+ expect(renderSpy).toHaveBeenCalledTimes(3);
55
+ expect(renderSpy).toHaveBeenLastCalledWith([expect.any(Function), expect.objectContaining({
56
+ called: true,
57
+ loading: false,
58
+ data: {
59
+ answer: 42
60
+ },
61
+ engine: expect.any(Object)
62
+ })]);
56
63
  });
57
- expect(renderFunction).toHaveBeenCalledTimes(2);
58
- expect(renderFunction).toHaveBeenLastCalledWith([doMutation, {
59
- called: true,
60
- loading: true,
61
- engine: expect.any(Object)
62
- }]);
63
- expect(mockBackend.target).toHaveBeenCalledTimes(1);
64
- await waitFor(() => getByText(/data: /i));
65
- expect(renderFunction).toHaveBeenCalledTimes(3);
66
- expect(renderFunction).toHaveBeenLastCalledWith([doMutation, {
67
- called: true,
68
- loading: false,
69
- data: {
70
- answer: 42
71
- },
72
- engine: expect.any(Object)
73
- }]);
74
- expect(getByText(/data: /i)).toHaveTextContent("data: 42");
75
64
  });
76
65
  });
@@ -23,7 +23,7 @@ export class CustomDataLink {
23
23
 
24
24
  const customResource = this.data[query.resource];
25
25
 
26
- if (!customResource) {
26
+ if (customResource === undefined) {
27
27
  if (this.failOnMiss) {
28
28
  throw new Error("No data provided for resource type ".concat(query.resource, "!"));
29
29
  }
@@ -3,7 +3,12 @@
3
3
  * the developer documentation:
4
4
  * https://docs.dhis2.org/master/en/developer/html/dhis2_developer_manual_full.html
5
5
  */
6
- // POST to 'fileResources' (upload a file resource)
6
+ // Post to 'dataValues' (send/update a data value; endpoint doesn't support JSON)
7
+ // For file-uploads too
8
+ export const isDataValue = (type, {
9
+ resource
10
+ }) => type === 'create' && (resource === 'dataValues' || resource === 'dataValues/file'); // POST to 'fileResources' (upload a file resource)
11
+
7
12
  export const isFileResourceUpload = (type, {
8
13
  resource
9
14
  }) => type === 'create' && resource === 'fileResources'; // POST to 'messageConversations/attachments' (upload a message conversation attachment)
@@ -1,4 +1,21 @@
1
- import { isFileResourceUpload, isMessageConversationAttachment, isStaticContentUpload, isAppInstall, isSvgConversion } from './multipartFormDataMatchers';
1
+ import { isFileResourceUpload, isMessageConversationAttachment, isStaticContentUpload, isAppInstall, isSvgConversion, isDataValue } from './multipartFormDataMatchers';
2
+ describe('isDataValue', () => {
3
+ it('returns true for a POST to "dataValues"', () => {
4
+ expect(isDataValue('create', {
5
+ resource: 'dataValues'
6
+ })).toEqual(true);
7
+ });
8
+ it('returns true for a POST to "dataValues/file"', () => {
9
+ expect(isDataValue('create', {
10
+ resource: 'dataValues/file'
11
+ })).toEqual(true);
12
+ });
13
+ it('returns false for a POST to a different resource', () => {
14
+ expect(isDataValue('create', {
15
+ resource: 'somethingElse'
16
+ })).toEqual(false);
17
+ });
18
+ });
2
19
  describe('isFileResourceUpload', () => {
3
20
  it('returns true for a POST to "fileResources"', () => {
4
21
  expect(isFileResourceUpload('create', {