Skip to content

Commit

Permalink
fix(products): Add description field on products
Browse files Browse the repository at this point in the history
- a product should have a description
  • Loading branch information
Heisjabo authored and teerenzo committed Jun 24, 2024
1 parent c00a53c commit ed6adcd
Show file tree
Hide file tree
Showing 8 changed files with 295 additions and 277 deletions.
5 changes: 5 additions & 0 deletions __test__/prod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const dummy = [
{
name: "MacBook Pro M3",
description: "product description",
images: [
"https://www.notebookcheck.net/fileadmin/_processed_/a/3/csm_IMG_1008_47c6b245b1.jpg",
"https://www.notebookcheck.net/fileadmin/_processed_/a/3/csm_IMG_1008_47c6b245b1.jpg",
Expand All @@ -20,6 +21,7 @@ export const dummy = [
},
{
name: "MacBook Pro M2",
description: "product description",
images: [
"https://www.notebookcheck.net/fileadmin/_processed_/a/3/csm_IMG_1008_47c6b245b1.jpg",
"https://www.notebookcheck.net/fileadmin/_processed_/a/3/csm_IMG_1008_47c6b245b1.jpg",
Expand All @@ -39,6 +41,7 @@ export const dummy = [
},
{
name: "Iphone 13",
description: "product description",
images: [
"https://images.macrumors.com/t/egbqDs7OtftrKl9nJnbNgv1WET0=/1600x0/article-new/2021/09/Apple-iPhone-13-colors-lineup-2022.jpg",
"https://images.macrumors.com/t/egbqDs7OtftrKl9nJnbNgv1WET0=/1600x0/article-new/2021/09/Apple-iPhone-13-colors-lineup-2022.jpg",
Expand All @@ -58,6 +61,7 @@ export const dummy = [
},
{
name: "Logitech Mouse",
description: "product description",
images: [
"https://images.macrumors.com/t/egbqDs7OtftrKl9nJnbNgv1WET0=/1600x0/article-new/2021/09/Apple-iPhone-13-colors-lineup-2022.jpg",
"https://images.macrumors.com/t/egbqDs7OtftrKl9nJnbNgv1WET0=/1600x0/article-new/2021/09/Apple-iPhone-13-colors-lineup-2022.jpg",
Expand All @@ -77,6 +81,7 @@ export const dummy = [
},
{
name: "Mechanical Keyboard",
description: "product description",
images: [
"https://images.macrumors.com/t/egbqDs7OtftrKl9nJnbNgv1WET0=/1600x0/article-new/2021/09/Apple-iPhone-13-colors-lineup-2022.jpg",
"https://images.macrumors.com/t/egbqDs7OtftrKl9nJnbNgv1WET0=/1600x0/article-new/2021/09/Apple-iPhone-13-colors-lineup-2022.jpg",
Expand Down
3 changes: 3 additions & 0 deletions __test__/product.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const dummySeller = {

const product:any = {
name: "pens",
description: "Product description",
images: ["image1.jpg", "image2.jpg", "image3.jpg", "image4.jpg"],
stockQuantity: 8,

Expand Down Expand Up @@ -240,6 +241,7 @@ const imagePaths = [
const response = await request(app)
.post('/api/v1/products')
.field("name", "pens")
.field("description", "Product description")
.attach("images",images[0],{filename:"1680673137259.jpg"})
.attach("images",images[1],{filename:"1680673137259.jpg"})
.attach("images",images[2],{filename:"1680673137259.jpg"})
Expand All @@ -258,6 +260,7 @@ const imagePaths = [
const response = await request(app)
.post('/api/v1/products')
.field("name", "pens")
.field("description", "Product description")
.attach("images",images[0],{filename:"1680673137259.jpg"})
.attach("images",images[1],{filename:"1680673137259.jpg"})
.attach("images",images[2],{filename:"1680673137259.jpg"})
Expand Down
3 changes: 2 additions & 1 deletion src/controllers/productControllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const addProducts = async (req: Request, res: Response) => {
}
//@ts-ignore
const loggedIn:any = req.user;
const {name,stockQuantity,price,discount,categoryID,expiryDate}:ProductType = req.body;
const {name,stockQuantity,price,discount, description, categoryID,expiryDate}:ProductType = req.body;
const product = {
name,
images:ulr,
Expand All @@ -99,6 +99,7 @@ export const addProducts = async (req: Request, res: Response) => {
categoryID,
userId : loggedIn.id,
expiryDate,
description,
createdAt: new Date(),
updatedAt: new Date()
};
Expand Down
Loading

0 comments on commit ed6adcd

Please sign in to comment.