Skip to content

Commit 0502a52

Browse files
chore: add mock to favorite routes
1 parent 6baa328 commit 0502a52

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

src/__tests__/pages/FoodDetails.spec.tsx

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,23 @@ const apiMock = new AxiosMock(api);
4747

4848
describe('Orders', () => {
4949
it('should be able to list the food', async () => {
50+
const favorites = [
51+
{
52+
id: 2,
53+
name: 'Veggie',
54+
description:
55+
'Macarrão com pimentão, ervilha e ervas finas colhidas no himalaia.',
56+
price: '21.90',
57+
category: 2,
58+
image_url:
59+
'https://storage.googleapis.com/golden-wind/bootcamp-gostack/desafio-food/food2.png',
60+
thumbnail_url:
61+
'https://storage.googleapis.com/golden-wind/bootcamp-gostack/desafio-gorestaurant-mobile/veggie.png',
62+
},
63+
];
64+
65+
apiMock.onGet('/favorites').reply(200, favorites);
66+
5067
const item = {
5168
id: 1,
5269
name: 'Ao molho',
@@ -96,6 +113,23 @@ describe('Orders', () => {
96113
});
97114

98115
it('should be able to increment food quantity', async () => {
116+
const favorites = [
117+
{
118+
id: 2,
119+
name: 'Veggie',
120+
description:
121+
'Macarrão com pimentão, ervilha e ervas finas colhidas no himalaia.',
122+
price: '21.90',
123+
category: 2,
124+
image_url:
125+
'https://storage.googleapis.com/golden-wind/bootcamp-gostack/desafio-food/food2.png',
126+
thumbnail_url:
127+
'https://storage.googleapis.com/golden-wind/bootcamp-gostack/desafio-gorestaurant-mobile/veggie.png',
128+
},
129+
];
130+
131+
apiMock.onGet('/favorites').reply(200, favorites);
132+
99133
const item = {
100134
id: 1,
101135
name: 'Ao molho',
@@ -151,6 +185,23 @@ describe('Orders', () => {
151185
});
152186

153187
it('should be able to decrement food quantity', async () => {
188+
const favorites = [
189+
{
190+
id: 2,
191+
name: 'Veggie',
192+
description:
193+
'Macarrão com pimentão, ervilha e ervas finas colhidas no himalaia.',
194+
price: '21.90',
195+
category: 2,
196+
image_url:
197+
'https://storage.googleapis.com/golden-wind/bootcamp-gostack/desafio-food/food2.png',
198+
thumbnail_url:
199+
'https://storage.googleapis.com/golden-wind/bootcamp-gostack/desafio-gorestaurant-mobile/veggie.png',
200+
},
201+
];
202+
203+
apiMock.onGet('/favorites').reply(200, favorites);
204+
154205
const item = {
155206
id: 1,
156207
name: 'Ao molho',
@@ -224,6 +275,23 @@ describe('Orders', () => {
224275
});
225276

226277
it('should not be able to decrement food quantity below than 1', async () => {
278+
const favorites = [
279+
{
280+
id: 2,
281+
name: 'Veggie',
282+
description:
283+
'Macarrão com pimentão, ervilha e ervas finas colhidas no himalaia.',
284+
price: '21.90',
285+
category: 2,
286+
image_url:
287+
'https://storage.googleapis.com/golden-wind/bootcamp-gostack/desafio-food/food2.png',
288+
thumbnail_url:
289+
'https://storage.googleapis.com/golden-wind/bootcamp-gostack/desafio-gorestaurant-mobile/veggie.png',
290+
},
291+
];
292+
293+
apiMock.onGet('/favorites').reply(200, favorites);
294+
227295
const item = {
228296
id: 1,
229297
name: 'Ao molho',
@@ -289,6 +357,23 @@ describe('Orders', () => {
289357
});
290358

291359
it('should be able to increment an extra item quantity', async () => {
360+
const favorites = [
361+
{
362+
id: 2,
363+
name: 'Veggie',
364+
description:
365+
'Macarrão com pimentão, ervilha e ervas finas colhidas no himalaia.',
366+
price: '21.90',
367+
category: 2,
368+
image_url:
369+
'https://storage.googleapis.com/golden-wind/bootcamp-gostack/desafio-food/food2.png',
370+
thumbnail_url:
371+
'https://storage.googleapis.com/golden-wind/bootcamp-gostack/desafio-gorestaurant-mobile/veggie.png',
372+
},
373+
];
374+
375+
apiMock.onGet('/favorites').reply(200, favorites);
376+
292377
const item = {
293378
id: 1,
294379
name: 'Ao molho',
@@ -350,6 +435,23 @@ describe('Orders', () => {
350435
});
351436

352437
it('should be able to decrement an extra item quantity', async () => {
438+
const favorites = [
439+
{
440+
id: 2,
441+
name: 'Veggie',
442+
description:
443+
'Macarrão com pimentão, ervilha e ervas finas colhidas no himalaia.',
444+
price: '21.90',
445+
category: 2,
446+
image_url:
447+
'https://storage.googleapis.com/golden-wind/bootcamp-gostack/desafio-food/food2.png',
448+
thumbnail_url:
449+
'https://storage.googleapis.com/golden-wind/bootcamp-gostack/desafio-gorestaurant-mobile/veggie.png',
450+
},
451+
];
452+
453+
apiMock.onGet('/favorites').reply(200, favorites);
454+
353455
const item = {
354456
id: 1,
355457
name: 'Ao molho',

0 commit comments

Comments
 (0)