@rohitbakoliya/test-gen
Version:
Quickly generate test cases for stress testing using interactive CLI.
35 lines (34 loc) • 1.6 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const RndString_1 = __importDefault(require("../logic/RndString"));
describe('Random String tests', () => {
const patterns = ['abc xyz|', '12based?1~', '/', ''];
test('string => should return string with correct length', () => {
patterns.forEach(pattern => {
const { result } = RndString_1.default({ pattern });
expect(result).toBeString();
expect(result.length).toBeWithin(0, Math.max(0, result.length + 1));
});
});
test('string => should match with input pattern', () => {
patterns.forEach(pattern => {
const { result } = RndString_1.default({ pattern });
expect(result).toMatch(new RegExp(`${pattern}`));
});
});
test('should return correct expression', () => {
const expressions = [
/[a-z0-9._+-]{1,20}@[a-z0-9]{3,15}\.[a-z]{2,4}/,
/(January|February|March|April|May|June|July|August|September|October|November|December) ([1-9]|[12][0-9]|3[01]), (19|20)[0-9][0-9]/,
];
expressions.forEach(expression => {
expect(RndString_1.default({ pattern: expression }).result).toMatch(expression);
});
});
test('should return expression of correct length', () => {
expect(RndString_1.default({ pattern: /[A-Z]{5,10}/ }).result).toMatch(/^.{5,10}$/);
});
});