@rohitbakoliya/test-gen
Version:
Quickly generate test cases for stress testing using interactive CLI.
38 lines (37 loc) • 1.64 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const RndDirectedUnweighted_1 = __importDefault(require("../../logic/graphs/RndDirectedUnweighted"));
describe('Random Generated Directed Unweighted Graph Tests', () => {
const nodesRange = [70, 179];
const edgesRange = [250, 500];
const { result, nodes, edges } = RndDirectedUnweighted_1.default({ nodesRange, edgesRange });
test('should return edges', () => {
expect(result).toBeArray();
});
test('nodes count should be in range', () => {
expect(nodes).toBeWithin(nodesRange[0], nodesRange[1] + 1);
});
test('edges count should be in range', () => {
expect(edges).toBeWithin(edgesRange[0], edgesRange[1] + 1);
});
test('max possible edges test', () => {
expect(edges).toBeLessThanOrEqual((nodes * (nodes + 1)) / 2);
});
test('should return correct nodes values i.e [1,N]', () => {
expect(result).toSatisfyAll(pairs => pairs[0] >= 1 && pairs[0] <= nodes && pairs[1] >= 1 && pairs[1] <= nodes);
});
test('should not contain any self loop', () => {
expect(result).toSatisfyAll(pairs => pairs[0] !== pairs[1]);
});
test('should not contain any parallel edge', () => {
const edgeSet = new Set();
result.forEach(edge => {
const [u, v] = edge;
edgeSet.add(`${u},${v}`);
});
expect(edgeSet.size).toEqual(edges);
});
});