Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit and integration test for stock out #64

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@
"SwitchCase": 1
}
]
},
"globals": {
"jest": true
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"scripts": {
"cz": "cz",
"test": "jest",
"test": "jest --testTimeout=25000 --runInBand",
"semantic-release": "semantic-release",
"prepare": "husky"
},
Expand Down
10 changes: 9 additions & 1 deletion src/add-feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ async function selectFeature(configs) {
choices: remainingFeatures.map((ft) => ({
name: FEATURES[ft],
value: ft,
}))
})),
when: function (answers){
const argv = process.argv;
if (!argv[4]){
return true;
}
answers.name = argv[4];
return false;
}
}
]);

Expand Down
34 changes: 32 additions & 2 deletions src/features/stock-out.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,15 @@ async function getStockOutConfigs({
type: 'input',
name: 'form_name',
message: 'Enter stock out form ID',
default: 'stock_out'
default: 'stock_out',
when: function (answers){
const argv = process.argv;
if (!argv[5]){
return true;
}
answers.form_name = argv[5];
return false;
}
},
{
type: 'list',
Expand All @@ -279,12 +287,34 @@ async function getStockOutConfigs({
value: 'weekly_qty'
}
],
when: function (answers){
const argv = process.argv;
if (!argv[6]){
return true;
}
answers.formular = argv[6];
return false;
}
},
...languages.map((language) => ({
type: 'input',
name: `title.${language}`,
message: `Enter stock out form title in ${language}`,
default: 'Stock Out'
default: 'Stock Out',
when: function (answers){
const argv = process.argv;
if (!argv[7]){
return true;
}
const answer = {
title:{
'en': argv[7].split(',')[0],
'fr': argv[7].split(',')[1]
}
};
Object.assign(answers, answer);
return false;
}
}))
]);
return configs;
Expand Down
132 changes: 132 additions & 0 deletions test/mocks/mocks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,92 @@
module.exports = {
stockOutConfigs: {
features: {
stock_count: {
form_name: 'stock_count',
contact_types: [
{
contact_type: 'c62_chw',
role: 'chw',
place_type: 'c60_chw_site'
},
{
contact_type: 'c52_supervisor',
role: 'supervisor',
place_type: 'c50_supervision_area'
}
],
type: 'action',
title: {
en: 'Stock count',
fr: 'Stock count'
}
},
stock_out: {
form_name: 'stock_out',
formular: 'item_danger_qty',
title: {
en: 'Stock Out Title',
fr: 'Titre du Stock'
},
},
},
levels: {
1: {
contact_type: 'c62_chw',
role: 'chw',
place_type: 'c62_chw_site'
},
2: {
contact_type: 'c52_supervisor',
role: 'supervisor',
place_type: 'c50_supervision_area'
},
},
languages: ['en', 'fr'],
items: {
paracetamol: {
name: 'paracetamol',
label: {
en: 'Paracetamol',
fr: 'Paracetamole'
},
isInSet: 'Y',
set: {
label: {
en: 'Box of 8',
fr: 'Boite de 8'
},
count: '8'
},
unit: {
label: {
en: 'Tablet',
fr: 'Comprimes'
}
},
warning_total: '20',
danger_total: '15',
max_total: '15',
category: 'malaria'
}
},
categories: {
malaria: {
name: 'malaria',
label: {
fr: 'Categorie'
},
description: {
fr: 'Categorie'
}
}
},
useItemCategory: true,
defaultLanguage: 'fr',
version: '1.1.3',
last_update_date: '2024-10-21T11:09:33.013Z'
},

stockCountScenario: {
initScenario: [
'init',
Expand Down Expand Up @@ -41,6 +129,50 @@ module.exports = {
'paracetamol___count'
]

},

stockOutScenario: {
initScenario: [
'init',
'2_levels',
'c62_chw',
'chw',
'c52_supervisor',
'supervisor',
'Y',
'stock_count',
'[{contact_type: \'c62_chw\', role: \'chw\', place_type: \'c60_chw_site\' },{contact_type: \'c52_supervisor\',role: \'supervisor\',place_type: \'c50_supervision_area\'}]',
'action',
'end_of_week',
['Stock count', 'Stock count'],
'patient_assessment_under_5',
'Y',
'now()',
'malaria',
['Category', 'Categorie'],
['Category', 'Categorie'],
'paracetamol',
['Paracetamol', 'Paracetamole'],
'Y',
['Box of 8', 'Boite de 8'],
8,
['Tablet', 'Comprimes'],
20,
15,
15,
'by_user',
0,
],
addStockOutFeatureScenario: [
'add', 'feature', 'stock_out', 'stock_out', 'item_danger_qty', ['Stock Out', 'Stock Out']
],
productsScenario: [
'paracetamol_at_hand___set',
'paracetamol_at_hand___unit',
'paracetamol_required___set',
'paracetamol_required___unit'
]

}
};

Expand Down
Loading
Loading