@rohitbakoliya/test-gen
Version:
Quickly generate test cases for stress testing using interactive CLI.
178 lines (177 loc) • 5.57 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.dwGraphQuestion = exports.duGraphQuestion = exports.uuGraphQuestion = exports.graphQuestion = exports.utreeQuestion = exports.wtreeQuestion = exports.treeQuestion = exports.permutationArrayQuestion = exports.arrayRangeQuestion = exports.arrayPatternQuestions = exports.gridQuestion = exports.arrayQuestion = exports.stringQuestion = exports.numberQuestion = exports.initialQuestions = void 0;
const chalk_1 = __importDefault(require("chalk"));
const validators_1 = require("./validators");
const constants_1 = require("../constants/constants");
exports.initialQuestions = [
{
type: 'input',
name: 'fileName',
message: 'Enter the Input file name',
default: () => 'input',
transformer: (fileName, _, flags) => {
if (flags.isFinal) {
return chalk_1.default.cyan(fileName + '.txt');
}
return fileName;
},
validate: validators_1.validateFileName,
},
{
type: 'input',
name: 'testCases',
message: 'Enter the number of test cases',
default: () => '0',
validate: validators_1.validateWholeNumber,
},
{
type: 'list',
name: 'type',
message: 'Choose type of test cases',
choices: ['Number', 'String', 'Array', 'Permutation Array', 'Grid', 'Tree', 'Graph'],
},
];
exports.numberQuestion = [
{
type: 'input',
name: 'min',
message: 'Minimum Possible value of Number',
default: () => `0`,
validate: validators_1.validateBigNumber,
},
{
type: 'input',
name: 'max',
default: () => `${constants_1.INT_MAX}`,
message: 'Maximum Possible value of Number',
validate: validators_1.validateBigNumber,
},
];
exports.stringQuestion = [
{
type: 'input',
name: 'pattern',
default: () => '[a-z]*',
message: 'Enter Pattern as Regular Expression',
validate: validators_1.validateRegex,
},
];
exports.arrayQuestion = [
{
type: 'input',
name: 'minSize',
message: 'Enter minmimum size of an Array',
validate: validators_1.validateNaturalNumber,
},
{
type: 'input',
name: 'maxSize',
message: 'Enter maximum size of an Array',
validate: validators_1.validateNaturalNumber,
},
{
type: 'list',
name: 'arrayGenType',
message: 'How do you want to generate array?',
choices: ['Using Regular Expression', 'Using Number Range'],
},
];
exports.gridQuestion = [
{
type: 'input',
name: 'minDim',
message: 'Enter minimum dimention of grid [comma separated]',
validate: validators_1.validateRange,
},
{
type: 'input',
name: 'maxDim',
message: 'Enter maximum dimention of grid [comma separated]',
validate: validators_1.validateRange,
},
{
type: 'list',
name: 'arrayGenType',
message: 'How do you want to generate array?',
choices: ['Using Regular Expression', 'Using Number Range'],
},
];
exports.arrayPatternQuestions = exports.stringQuestion;
exports.arrayRangeQuestion = exports.numberQuestion;
exports.permutationArrayQuestion = [
{
type: 'input',
name: 'minSize',
message: 'Enter minimum size of Permutation Array',
validate: validators_1.validateNaturalNumber,
},
{
type: 'input',
name: 'maxSize',
message: 'Enter maximum size of Permutation Array',
validate: validators_1.validateNaturalNumber,
},
];
exports.treeQuestion = [
{
type: 'list',
name: 'treeType',
message: 'Type of tree',
choices: ['Weighted Tree', 'Unweighted Tree'],
},
];
exports.wtreeQuestion = [
{
type: 'input',
name: 'nodesRange',
message: 'Enter the nodes range [separated by comma]',
validate: validators_1.validateRange,
},
{
type: 'input',
name: 'wtRange',
message: 'Enter the weight range [separated by comma]',
validate: validators_1.validateRange,
},
];
exports.utreeQuestion = [exports.wtreeQuestion[0]];
exports.graphQuestion = [
{
type: 'list',
name: 'graphType',
message: 'Type of tree',
choices: [
'Directed Weighted Graph',
'Directed Unweighted Graph',
'Undirected Unweighted Graph',
],
},
];
exports.uuGraphQuestion = [
{
type: 'input',
name: 'nodesRange',
message: 'Enter the nodes range [separated by comma]',
validate: validators_1.validateRange,
},
{
type: 'input',
name: 'edgesRange',
message: 'Enter the edges range [separated by comma]',
validate: validators_1.validateRange,
},
];
exports.duGraphQuestion = exports.uuGraphQuestion;
exports.dwGraphQuestion = [
...exports.uuGraphQuestion,
{
type: 'input',
name: 'wtRange',
message: 'Enter the weight range [separated by comma]',
validate: validators_1.validateRange,
},
];