-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-test-files.js
37 lines (30 loc) · 1.29 KB
/
generate-test-files.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const fs = require('fs');
const path = require('path');
const slugify = require('slugify');
const featureDirPath = process.argv.pop();
const acitityFilePath = process.argv.pop();
<<<<<<< HEAD
=======
console.log("args", acitityFilePath, featureDirPath);
>>>>>>> 5b54042266e107cad1a14af0e7d63552a1daf064
const activityData = JSON.parse(fs.readFileSync(acitityFilePath, { encoding: 'utf8' }));
activityData.activity.map((activity, activityIdx) => {
activity.action.map((action, actionIdx) => {
const targetPath = path.join(featureDirPath, slugify(activity.activity_verbal) + '-' + slugify(action.action_verbal) + '.feature');
let feature = `
Feature: ${action.action_verbal}
As a/an ${activity.role}
I ${action.intenttype} ${action.action_verbal}
so that ${action.goal}
`;
action.operation.map(operation => {
feature += `
Scenario: ${operation.intenttype + ' ' + operation.operation_verbal}
`;
operation.condition.map (condition => {
feature += ` ${condition.conditionttype.slice(0,1).toUpperCase() + condition.conditionttype.slice(1).toLowerCase() } ${condition.criteria}\n`;
});
});
fs.writeFile(targetPath, feature, 'utf-8', (err, data) => console.log(err ? err : "success: " + targetPath));
})
})