Track stock on testing

master
Mark Moffat 2019-06-09 22:19:35 +09:30
parent fa5f27f989
commit 3c38a6f9da
3 changed files with 20 additions and 8 deletions

5
app.js
View File

@ -349,6 +349,11 @@ initDb(config.databaseConnectionString, (err, db) => {
}); });
}); });
// Set trackStock for testing
if(process.env.NODE_ENV === 'test'){
config.trackStock = true;
}
// run indexing // run indexing
common.runIndexing(app) common.runIndexing(app)
.then(app.listen(app.get('port'))) .then(app.listen(app.get('port')))

View File

@ -8,7 +8,8 @@
"productPublished": "true", "productPublished": "true",
"productTags": "organic, jacket", "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\"]}}", "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", "productPermalink": "5-panel-camp-cap",
@ -18,7 +19,8 @@
"productPublished": "true", "productPublished": "true",
"productTags": "panel, cap", "productTags": "panel, cap",
"productOptions": "{\"colour\":{\"optName\":\"colour\",\"optLabel\":\"Select colour\",\"optType\":\"select\",\"optOptions\":[\"Heather green\",\"Burnt orange\",\"Slate grey\",\"Navy blue\"]}}", "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", "productPermalink": "ranger-boot",
@ -28,7 +30,8 @@
"productPublished": "true", "productPublished": "true",
"productTags": "ranger, boot, leather", "productTags": "ranger, boot, leather",
"productImage": "/uploads/ranger-boot/boot_grande.jpg", "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", "productPermalink": "whitney-pullover",
@ -38,7 +41,8 @@
"productPublished": "true", "productPublished": "true",
"productImage": "/uploads/whitney-pullover/WhitneyPullover_Full_58e7b8d6-b939-4701-9e1d-9d853dff60ed_grande.jpeg", "productImage": "/uploads/whitney-pullover/WhitneyPullover_Full_58e7b8d6-b939-4701-9e1d-9d853dff60ed_grande.jpeg",
"productTags": "whitney, pullover", "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", "productPermalink": "scout-backpack",
@ -48,7 +52,8 @@
"productPublished": "true", "productPublished": "true",
"productTags": "backpack, organic", "productTags": "backpack, organic",
"productImage": "/uploads/scout-backpack/scout-backpack_a035275d-8975-4a05-8456-5e1ec35f020f_grande.jpg", "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", "productPermalink" : "hudderton-backpack",
@ -58,7 +63,8 @@
"productPublished" : "true", "productPublished" : "true",
"productTags" : "backpack", "productTags" : "backpack",
"productOptions" : "", "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", "productPermalink" : "ayres-chambray",
@ -68,7 +74,8 @@
"productPublished" : "true", "productPublished" : "true",
"productTags" : "shirt", "productTags" : "shirt",
"productOptions" : "{\"Size\":{\"optName\":\"Size\",\"optLabel\":\"Select size\",\"optType\":\"select\",\"optOptions\":[\"S\",\"M\",\"L\"]}}", "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": [ "customers": [

View File

@ -7,7 +7,7 @@
"start": "node app.js", "start": "node app.js",
"deploy": "gulp deploy", "deploy": "gulp deploy",
"testdata": "node lib/testdata.js", "testdata": "node lib/testdata.js",
"test": "ava test/test.js --verbose" "test": "NODE_ENV=test ava test/test.js --verbose"
}, },
"dependencies": { "dependencies": {
"ajv": "^6.10.0", "ajv": "^6.10.0",