@rohitbakoliya/test-gen
Version:
Quickly generate test cases for stress testing using interactive CLI.
41 lines (40 loc) • 1.68 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const RndUndirectedUnweighted_1 = __importDefault(require("../../logic/graphs/RndUndirectedUnweighted"));
describe('Random Generated Undirected Unweighted Graph Tests', () => {
const nodesRange = [100, 200];
const edgesRange = [500, 1000];
const { result, edges, nodes } = RndUndirectedUnweighted_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,nodes]', () => {
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);
});
});