Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return reqInfo.utils.createResponse$(() => {
if (reqInfo.id === 'placeOrder') {
//should make a service call to clear cart here.
// this.driver.cartService.clear(reqInfo.req.body.orderId).subscribe();
this.populateOrder();
}
return {
body: this.order,
status: STATUS.OK
};
});
}
it('should return the returned value from createResponse$', () => {
expect(result).toEqual({
body: stubCart,
status: STATUS.OK
});
});
it('should return the returned value from createResponse$', () => {
expect(result).toEqual({
body: stubCart,
status: STATUS.OK
});
});
if (reqInfo.id === 'addToCart') {
const matchedProductIndex = this.getMatchedProductIndex(
reqInfo.req.body.productId
);
if (matchedProductIndex > -1) {
this.addQtyToCartProduct(reqInfo.req.body.qty, matchedProductIndex);
} else {
this.addProductToCart(reqInfo.req.body);
}
} else if (reqInfo.id === 'clear') {
this.clearCart();
}
return {
body: this.cart,
status: STATUS.OK
};
});
}
return reqInfo.utils.createResponse$(() => {
if(reqInfo.id === "addToCart") {
let matchedProductIndex = this.getMatchedProductIndex(reqInfo.req.body.productId);
if(matchedProductIndex > -1) {
this.addQtyToCartProduct(reqInfo.req.body.qty, matchedProductIndex);
} else {
this.addProductToCart(reqInfo.req.body);
}
}
return {
body: this.cart,
status: STATUS.OK
}
})
}
return reqInfo.utils.createResponse$(() => {
return {
body: this.products.slice(0,4),
status: STATUS.OK
};
});
}
return reqInfo.utils.createResponse$(() => {
return {
body: {
category: this.category,
categoryPageConfigurationState: this.categoryPageConfigurationState,
products: this.productInMemoryBackendService.products
},
status: STATUS.OK
};
});
}
if (reqInfo.id === 'addToCart') {
const matchedProductIndex = this.getMatchedProductIndex(
reqInfo.req.body.productId
);
if (matchedProductIndex > -1) {
this.addQtyToCartProduct(reqInfo.req.body.qty, matchedProductIndex);
} else {
this.addProductToCart(reqInfo.req.body);
}
} else if (reqInfo.id === 'clear') {
this.clearCart();
}
return {
body: this.cart,
status: STATUS.OK
};
});
}
return reqInfo.utils.createResponse$(() => {
return {
body: this.products.splice(1,4),
status: STATUS.OK
};
});
}
return reqInfo.utils.createResponse$(() => {
return {
body: this.products.slice(0,4),
status: STATUS.OK
};
});
}