From 3c38a6f9dafe187880531fb7ddd341761b200238 Mon Sep 17 00:00:00 2001 From: Mark Moffat Date: Sun, 9 Jun 2019 22:19:35 +0930 Subject: [PATCH] Track stock on testing --- app.js | 5 +++++ bin/testdata.json | 21 ++++++++++++++------- package.json | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app.js b/app.js index ae3bde3..9f4e6f1 100644 --- a/app.js +++ b/app.js @@ -349,6 +349,11 @@ initDb(config.databaseConnectionString, (err, db) => { }); }); + // Set trackStock for testing + if(process.env.NODE_ENV === 'test'){ + config.trackStock = true; + } + // run indexing common.runIndexing(app) .then(app.listen(app.get('port'))) diff --git a/bin/testdata.json b/bin/testdata.json index 64b17dd..3b2504b 100644 --- a/bin/testdata.json +++ b/bin/testdata.json @@ -8,7 +8,8 @@ "productPublished": "true", "productTags": "organic, jacket", "productOptions": "{\"Size\":{\"optName\":\"Size\",\"optLabel\":\"Select size\",\"optType\":\"select\",\"optOptions\":[\"S\",\"M\",\"L\",\"XL\"]},\"Colour\":{\"optName\":\"Colour\",\"optLabel\":\"Select colour\",\"optType\":\"select\",\"optOptions\":[\"Harvest\",\"Navy\"]}}", - "productImage": "/uploads/duckworth-jacket/woolfill-jacket_6c39ae23-c0c8-4821-85f4-4b5d64333c62_grande.jpg" + "productImage": "/uploads/duckworth-jacket/woolfill-jacket_6c39ae23-c0c8-4821-85f4-4b5d64333c62_grande.jpg", + "productStock": 10 }, { "productPermalink": "5-panel-camp-cap", @@ -18,7 +19,8 @@ "productPublished": "true", "productTags": "panel, cap", "productOptions": "{\"colour\":{\"optName\":\"colour\",\"optLabel\":\"Select colour\",\"optType\":\"select\",\"optOptions\":[\"Heather green\",\"Burnt orange\",\"Slate grey\",\"Navy blue\"]}}", - "productImage": "/uploads/5-panel-cap/5-panel-hat_4ee20a27-8d5a-490e-a2fc-1f9c3beb7bf5_grande.jpg" + "productImage": "/uploads/5-panel-cap/5-panel-hat_4ee20a27-8d5a-490e-a2fc-1f9c3beb7bf5_grande.jpg", + "productStock": 10 }, { "productPermalink": "ranger-boot", @@ -28,7 +30,8 @@ "productPublished": "true", "productTags": "ranger, boot, leather", "productImage": "/uploads/ranger-boot/boot_grande.jpg", - "productOptions": "{\"size\":{\"optName\":\"size\",\"optLabel\":\"Select size\",\"optType\":\"select\",\"optOptions\":[\"7.5\",\"8\",\"8.5\",\"9\",\"9.5\",\"10\",\"10.5\",\"11\"]}}" + "productOptions": "{\"size\":{\"optName\":\"size\",\"optLabel\":\"Select size\",\"optType\":\"select\",\"optOptions\":[\"7.5\",\"8\",\"8.5\",\"9\",\"9.5\",\"10\",\"10.5\",\"11\"]}}", + "productStock": 10 }, { "productPermalink": "whitney-pullover", @@ -38,7 +41,8 @@ "productPublished": "true", "productImage": "/uploads/whitney-pullover/WhitneyPullover_Full_58e7b8d6-b939-4701-9e1d-9d853dff60ed_grande.jpeg", "productTags": "whitney, pullover", - "productOptions": "{\"size\":{\"optName\":\"size\",\"optLabel\":\"Select size\",\"optType\":\"select\",\"optOptions\":[\"S\",\"M\",\"L\",\"XL\"]}}" + "productOptions": "{\"size\":{\"optName\":\"size\",\"optLabel\":\"Select size\",\"optType\":\"select\",\"optOptions\":[\"S\",\"M\",\"L\",\"XL\"]}}", + "productStock": 10 }, { "productPermalink": "scout-backpack", @@ -48,7 +52,8 @@ "productPublished": "true", "productTags": "backpack, organic", "productImage": "/uploads/scout-backpack/scout-backpack_a035275d-8975-4a05-8456-5e1ec35f020f_grande.jpg", - "productOptions": "{\"colour\":{\"optName\":\"colour\",\"optLabel\":\"Select colour\",\"optType\":\"select\",\"optOptions\":[\"Navy\",\"Moss\",\"Nutmeg\",\"Khaki\"]}}" + "productOptions": "{\"colour\":{\"optName\":\"colour\",\"optLabel\":\"Select colour\",\"optType\":\"select\",\"optOptions\":[\"Navy\",\"Moss\",\"Nutmeg\",\"Khaki\"]}}", + "productStock": 10 }, { "productPermalink" : "hudderton-backpack", @@ -58,7 +63,8 @@ "productPublished" : "true", "productTags" : "backpack", "productOptions" : "", - "productImage" : "/uploads/hudderton-backpack/hudderton-backpack_dc8afb13-448b-49d9-a042-5a163a97de8f_590x.jpg" + "productImage" : "/uploads/hudderton-backpack/hudderton-backpack_dc8afb13-448b-49d9-a042-5a163a97de8f_590x.jpg", + "productStock": 10 }, { "productPermalink" : "ayres-chambray", @@ -68,7 +74,8 @@ "productPublished" : "true", "productTags" : "shirt", "productOptions" : "{\"Size\":{\"optName\":\"Size\",\"optLabel\":\"Select size\",\"optType\":\"select\",\"optOptions\":[\"S\",\"M\",\"L\"]}}", - "productImage" : "/uploads/Ayres Chambray/chambray_5f232530-4331-492a-872c-81c225d6bafd_590x.jpg" + "productImage" : "/uploads/Ayres Chambray/chambray_5f232530-4331-492a-872c-81c225d6bafd_590x.jpg", + "productStock": 10 } ], "customers": [ diff --git a/package.json b/package.json index 5edbbd4..b412fc0 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "start": "node app.js", "deploy": "gulp deploy", "testdata": "node lib/testdata.js", - "test": "ava test/test.js --verbose" + "test": "NODE_ENV=test ava test/test.js --verbose" }, "dependencies": { "ajv": "^6.10.0",