Skip to content

Commit cd4a719

Browse files
committed
Fix tests
1 parent 819cfd0 commit cd4a719

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

packages/ra-core/src/controller/edit/EditBase.spec.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import {
1313
describe('EditBase', () => {
1414
it('should give access to the save function', async () => {
1515
const dataProvider = testDataProvider({
16-
// @ts-ignore
1716
getOne: () =>
17+
// @ts-ignore
1818
Promise.resolve({ data: { id: 12, test: 'previous' } }),
1919
update: jest.fn((_, { id, data, previousData }) =>
2020
Promise.resolve({ data: { id, ...previousData, ...data } })
@@ -44,8 +44,8 @@ describe('EditBase', () => {
4444

4545
it('should allow to override the onSuccess function', async () => {
4646
const dataProvider = testDataProvider({
47-
// @ts-ignore
4847
getOne: () =>
48+
// @ts-ignore
4949
Promise.resolve({ data: { id: 12, test: 'previous' } }),
5050
update: jest.fn((_, { id, data, previousData }) =>
5151
Promise.resolve({ data: { id, ...previousData, ...data } })
@@ -75,7 +75,9 @@ describe('EditBase', () => {
7575
{
7676
id: 12,
7777
data: { test: 'test' },
78+
previousData: { id: 12, test: 'previous' },
7879
resource: 'posts',
80+
meta: undefined,
7981
},
8082
{ snapshot: [] }
8183
);
@@ -84,8 +86,8 @@ describe('EditBase', () => {
8486

8587
it('should allow to override the onSuccess function at call time', async () => {
8688
const dataProvider = testDataProvider({
87-
// @ts-ignore
8889
getOne: () =>
90+
// @ts-ignore
8991
Promise.resolve({ data: { id: 12, test: 'previous' } }),
9092
update: jest.fn((_, { id, data, previousData }) =>
9193
Promise.resolve({ data: { id, ...previousData, ...data } })
@@ -117,7 +119,9 @@ describe('EditBase', () => {
117119
{
118120
id: 12,
119121
data: { test: 'test' },
122+
previousData: { id: 12, test: 'previous' },
120123
resource: 'posts',
124+
meta: undefined,
121125
},
122126
{ snapshot: [] }
123127
);
@@ -128,10 +132,9 @@ describe('EditBase', () => {
128132
it('should allow to override the onError function', async () => {
129133
jest.spyOn(console, 'error').mockImplementation(() => {});
130134
const dataProvider = testDataProvider({
131-
// @ts-ignore
132135
getOne: () =>
136+
// @ts-ignore
133137
Promise.resolve({ data: { id: 12, test: 'previous' } }),
134-
// @ts-ignore
135138
update: jest.fn(() => Promise.reject({ message: 'test' })),
136139
});
137140
const onError = jest.fn();
@@ -153,7 +156,9 @@ describe('EditBase', () => {
153156
{
154157
id: 12,
155158
data: { test: 'test' },
159+
previousData: { id: 12, test: 'previous' },
156160
resource: 'posts',
161+
meta: undefined,
157162
},
158163
{ snapshot: [] }
159164
);
@@ -162,10 +167,9 @@ describe('EditBase', () => {
162167

163168
it('should allow to override the onError function at call time', async () => {
164169
const dataProvider = testDataProvider({
165-
// @ts-ignore
166170
getOne: () =>
171+
// @ts-ignore
167172
Promise.resolve({ data: { id: 12, test: 'previous' } }),
168-
// @ts-ignore
169173
update: jest.fn(() => Promise.reject({ message: 'test' })),
170174
});
171175
const onError = jest.fn();
@@ -189,7 +193,9 @@ describe('EditBase', () => {
189193
{
190194
id: 12,
191195
data: { test: 'test' },
196+
previousData: { id: 12, test: 'previous' },
192197
resource: 'posts',
198+
meta: undefined,
193199
},
194200
{ snapshot: [] }
195201
);
@@ -199,8 +205,8 @@ describe('EditBase', () => {
199205

200206
it('should allow to override the transform function', async () => {
201207
const dataProvider = testDataProvider({
202-
// @ts-ignore
203208
getOne: () =>
209+
// @ts-ignore
204210
Promise.resolve({ data: { id: 12, test: 'previous' } }),
205211
update: jest.fn((_, { id, data, previousData }) =>
206212
Promise.resolve({ data: { id, ...previousData, ...data } })
@@ -239,8 +245,8 @@ describe('EditBase', () => {
239245

240246
it('should allow to override the transform function at call time', async () => {
241247
const dataProvider = testDataProvider({
242-
// @ts-ignore
243248
getOne: () =>
249+
// @ts-ignore
244250
Promise.resolve({ data: { id: 12, test: 'previous' } }),
245251
update: jest.fn((_, { id, data, previousData }) =>
246252
Promise.resolve({ data: { id, ...previousData, ...data } })

packages/ra-ui-materialui/src/button/SaveButton.spec.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ describe('<SaveButton />', () => {
173173
{
174174
id: '123',
175175
data: { id: 123, title: 'ipsum' },
176+
previousData: { id: 123, title: 'lorem' },
176177
resource: 'posts',
178+
meta: undefined,
177179
},
178180
{ snapshot: [] }
179181
);
@@ -224,7 +226,9 @@ describe('<SaveButton />', () => {
224226
{
225227
id: '123',
226228
data: { id: 123, title: 'ipsum' },
229+
previousData: { id: 123, title: 'lorem' },
227230
resource: 'posts',
231+
meta: undefined,
228232
},
229233
{ snapshot: [] }
230234
);

packages/ra-ui-materialui/src/detail/Edit.spec.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ describe('<Edit />', () => {
108108
});
109109
});
110110

111-
it("shoudln't display the Edit aside while loading with the emptyWhileLoading prop", async () => {
111+
it("shouldn't display the Edit aside while loading with the emptyWhileLoading prop", async () => {
112112
let resolveGetOne;
113113
const RenderedComponent = () => {
114114
const myDataProvider = {
@@ -390,7 +390,9 @@ describe('<Edit />', () => {
390390
{
391391
id: '123',
392392
data: { id: 123, title: 'ipsum' },
393+
previousData: { id: 123, title: 'lorem' },
393394
resource: 'foo',
395+
meta: undefined,
394396
},
395397
{ snapshot: [] }
396398
);
@@ -453,7 +455,9 @@ describe('<Edit />', () => {
453455
{
454456
id: '123',
455457
data: { id: 123, title: 'ipsum' },
458+
previousData: { id: 123, title: 'lorem' },
456459
resource: 'foo',
460+
meta: undefined,
457461
},
458462
{ snapshot: [] }
459463
);
@@ -510,7 +514,9 @@ describe('<Edit />', () => {
510514
{
511515
id: '123',
512516
data: { id: 123, title: 'ipsum' },
517+
previousData: { id: 123, title: 'lorem' },
513518
resource: 'foo',
519+
meta: undefined,
514520
},
515521
{ snapshot: [] }
516522
);
@@ -573,7 +579,9 @@ describe('<Edit />', () => {
573579
{
574580
id: '123',
575581
data: { id: 123, title: 'ipsum' },
582+
previousData: { id: 123, title: 'lorem' },
576583
resource: 'foo',
584+
meta: undefined,
577585
},
578586
{ snapshot: [] }
579587
);

0 commit comments

Comments
 (0)