archunit
Version:
ArchUnit TypeScript is an architecture testing library, to specify and assert architecture rules in your TypeScript app
45 lines • 2.62 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
const metrics_1 = require("../../src/metrics");
require("../../index");
describe('LCOM metrics project summary', () => {
const mockProjectPath = path_1.default.join(__dirname, 'mock-project', 'tsconfig.json');
describe('Project-wide LCOM metrics', () => {
it('should calculate project-wide LCOM metrics summary', async () => {
// Get project summary for LCOM metrics
const projectSummary = await (0, metrics_1.metrics)(mockProjectPath).lcom().summary();
// Verify we have valid project metrics
expect(projectSummary).toBeDefined();
expect(projectSummary.totalClasses).toBeGreaterThanOrEqual(0);
// Verify that all average metrics are valid numbers
expect(projectSummary.averageLCOM96a).toBeGreaterThanOrEqual(0);
expect(projectSummary.averageLCOM96b).toBeGreaterThanOrEqual(0);
expect(projectSummary.averageLCOM96b).toBeLessThanOrEqual(1);
expect(projectSummary.averageLCOM1).toBeGreaterThanOrEqual(0);
expect(projectSummary.averageLCOM2).toBeGreaterThanOrEqual(0);
expect(projectSummary.averageLCOM3).toBeGreaterThanOrEqual(0);
expect(projectSummary.averageLCOM4).toBeGreaterThanOrEqual(0);
expect(projectSummary.averageLCOM5).toBeGreaterThanOrEqual(0);
expect(projectSummary.averageLCOMStar).toBeGreaterThanOrEqual(0);
expect(projectSummary.averageLCOMStar).toBeLessThanOrEqual(1);
// Verify high cohesion class count is valid
expect(projectSummary.highCohesionClassCount).toBeGreaterThanOrEqual(0);
expect(projectSummary.highCohesionClassCount).toBeLessThanOrEqual(projectSummary.totalClasses);
});
it('should filter classes based on builder configuration', async () => {
// Get summary for a filtered set of classes
const filteredSummary = await (0, metrics_1.metrics)(mockProjectPath)
.withName('concrete-service.ts')
.lcom()
.summary();
// This should include just classes in concrete-service.ts
expect(filteredSummary).toBeDefined();
expect(filteredSummary.totalClasses).toBeGreaterThanOrEqual(0);
});
});
});
//# sourceMappingURL=lcom-summary-integration.spec.js.map
;