@@ -79,52 +79,41 @@ describe('Full flow', () => {
7979 revision : 1 ,
8080 } ) ;
8181 expect ( response . body ) . toHaveProperty ( 'openedAt' ) ;
82- // current = response.body;
82+ //current = response.body;
8383
84- // // /////////////////////////////////////////////////
85- // // 2. Add product item
86- // // /////////////////////////////////////////////////
87- // const twoPairsOfShoes = {
88- // quantity: 2,
89- // productId: 123,
90- // };
91- // response = await request(app)
92- // .post(`/v2 /shopping-carts/${shoppingCartId}/product-items`)
93- // .set('If-Match', currentRevision)
94- // .send(twoPairsOfShoes)
95- // .expect(200);
84+ ///////////////////////////////////////////////////
85+ // 2. Add product item
86+ ///////////////////////////////////////////////////
87+ const twoPairsOfShoes = {
88+ quantity : 2 ,
89+ productId : ' 123' ,
90+ } ;
91+ response = await request ( app )
92+ . post ( `/${ clientId } /shopping-carts/${ shoppingCartId } /product-items` )
93+ // .set('If-Match', currentRevision)
94+ . send ( twoPairsOfShoes )
95+ . expect ( 200 ) ;
9696
9797 // expect(response.headers['etag']).toBeDefined();
9898 // expect(response.headers['etag']).toMatch(/W\/"\d+.*"/);
9999 // currentRevision = response.headers['etag'];
100100
101- // response = await request(app)
102- // .get(`/v2 /shopping-carts/${shoppingCartId}`)
103- // .set('If-Not-Match', lastRevision)
104- // .expect(200);
101+ response = await request ( app )
102+ . get ( `/${ clientId } /shopping-carts/${ shoppingCartId } ` )
103+ // .set('If-Not-Match', lastRevision)
104+ . expect ( 200 ) ;
105105
106106 // expect(response.headers['etag']).toBe(currentRevision);
107107 // lastRevision = response.headers['etag'];
108108
109- // expect(response.body).toMatchObject({
110- // id: current.id,
111- // createdAt: current.createdAt,
112- // sessionId: shoppingCartId,
113- // city: null,
114- // content: null,
115- // country: null,
116- // email: null,
117- // firstName: null,
118- // items: [twoPairsOfShoes],
119- // lastName: null,
120- // line1: null,
121- // line2: null,
122- // middleName: null,
123- // mobile: null,
124- // province: null,
125- // userId: null,
126- // status: ShoppingCartStatus.Opened,
127- // });
109+ expect ( response . body ) . toMatchObject ( {
110+ _id : shoppingCartId ,
111+ clientId,
112+ status : ShoppingCartStatus . Opened ,
113+ productItems : [ twoPairsOfShoes ] ,
114+ confirmedAt : null ,
115+ revision : 1 ,
116+ } ) ;
128117 // expect(response.body.updatedAt).not.toBeNull();
129118 // current = response.body;
130119
@@ -136,7 +125,7 @@ describe('Full flow', () => {
136125 // quantity: 1,
137126 // };
138127 // response = await request(app)
139- // .post(`/v2 /shopping-carts/${shoppingCartId}/product-items`)
128+ // .post(`/${clientId} /shopping-carts/${shoppingCartId}/product-items`)
140129 // .set('If-Match', currentRevision)
141130 // .send(tShirt)
142131 // .expect(200);
@@ -146,7 +135,7 @@ describe('Full flow', () => {
146135 // currentRevision = response.headers['etag'];
147136
148137 // response = await request(app)
149- // .get(`/v2 /shopping-carts/${shoppingCartId}`)
138+ // .get(`/${clientId} /shopping-carts/${shoppingCartId}`)
150139 // .set('If-Not-Match', lastRevision)
151140 // .expect(200);
152141
@@ -186,7 +175,7 @@ describe('Full flow', () => {
186175 // };
187176 // response = await request(app)
188177 // .delete(
189- // `/v2/ shopping-carts/${shoppingCartId}/product-items?productId=${pairOfShoes.productId}&quantity=${pairOfShoes.quantity}`
178+ // `/shopping-carts/${shoppingCartId}/product-items?productId=${pairOfShoes.productId}&quantity=${pairOfShoes.quantity}`
190179 // )
191180 // .set('If-Match', currentRevision)
192181 // .expect(200);
@@ -196,7 +185,7 @@ describe('Full flow', () => {
196185 // currentRevision = response.headers['etag'];
197186
198187 // response = await request(app)
199- // .get(`/v2 /shopping-carts/${shoppingCartId}`)
188+ // .get(`/${clientId} /shopping-carts/${shoppingCartId}`)
200189 // .set('If-Not-Match', lastRevision)
201190 // .expect(200);
202191
@@ -238,7 +227,7 @@ describe('Full flow', () => {
238227 // };
239228
240229 // response = await request(app)
241- // .put(`/v2/ users/${userId}/shopping-carts/${shoppingCartId}`)
230+ // .put(`/users/${userId}/shopping-carts/${shoppingCartId}`)
242231 // .set('If-Match', currentRevision)
243232 // .send(confirmedData)
244233 // .expect(200);
@@ -248,7 +237,7 @@ describe('Full flow', () => {
248237 // currentRevision = response.headers['etag'];
249238
250239 // response = await request(app)
251- // .get(`/v2 /shopping-carts/${shoppingCartId}`)
240+ // .get(`/${clientId} /shopping-carts/${shoppingCartId}`)
252241 // .set('If-Not-Match', lastRevision)
253242 // .expect(200);
254243
@@ -269,7 +258,7 @@ describe('Full flow', () => {
269258 // current = response.body;
270259
271260 // // response = await request(app)
272- // // .get(`/shopping-carts/${shoppingCartId}`)
261+ // // .get(`/${clientId}/ shopping-carts/${shoppingCartId}`)
273262 // // .expect(200);
274263
275264 // // const { updatedAt, ...currentWithoutUpdatedAt } = current;
@@ -286,15 +275,15 @@ describe('Full flow', () => {
286275 // // // 4. Try to add product item
287276 // // // It should fail, as cart is already confirmed
288277 // // await request(app)
289- // // .post(`/shopping-carts/${shoppingCartId}`)
278+ // // .post(`/${clientId}/ shopping-carts/${shoppingCartId}`)
290279 // // .send({
291280 // // ...current,
292281 // // items: [twoPairsOfShoes, tShirt],
293282 // // })
294283 // // .expect(412);
295284
296285 // // response = await request(app)
297- // // .get(`/shopping-carts/${shoppingCartId}`)
286+ // // .get(`/${clientId}/ shopping-carts/${shoppingCartId}`)
298287 // // .expect(200);
299288
300289 // // expect(response.body).toMatchObject(current);
0 commit comments