UNPKG

archunit

Version:

ArchUnit TypeScript is an architecture testing library, to specify and assert architecture rules in your TypeScript app

129 lines 5.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const __1 = require("../.."); describe('Metrics Pattern Matching Integration', () => { const tsConfigPath = './tsconfig.test.json'; describe('withName() method', () => { it('should filter classes by filename pattern', async () => { const violations = await (0, __1.metrics)(tsConfigPath) .withName('*.spec.ts') .lcom() .lcom96a() .shouldBeBelow(1.0) .check(); // Should pass since we're only looking at test files expect(violations.length).toBeGreaterThanOrEqual(0); }); it('should filter classes by exact filename', async () => { const violations = await (0, __1.metrics)(tsConfigPath) .withName('metrics.ts') .lcom() .lcom96a() .shouldBeBelow(1.0) .check(); // Should pass if metrics.ts files exist expect(violations.length).toBeGreaterThanOrEqual(0); }); }); describe('inPath() method', () => { it('should filter classes by full path pattern', async () => { const violations = await (0, __1.metrics)(tsConfigPath) .inPath('**/metrics/**') .lcom() .lcom96a() .shouldBeBelow(1.0) .check(); // Should pass since we're looking at metrics files expect(violations.length).toBeGreaterThanOrEqual(0); }); it('should filter classes by specific path components', async () => { const violations = await (0, __1.metrics)(tsConfigPath) .inPath('**/fluentapi/**') .lcom() .lcom96a() .shouldBeBelow(1.0) .check(); // Should pass if fluentapi files exist expect(violations.length).toBeGreaterThanOrEqual(0); }); }); describe('inFolder() method', () => { it('should filter classes by folder pattern', async () => { const violations = await (0, __1.metrics)(tsConfigPath) .inFolder('**/metrics') .lcom() .lcom96a() .shouldBeBelow(1.0) .check(); // Should pass since we're looking at metrics folders expect(violations.length).toBeGreaterThanOrEqual(0); }); it('should filter classes by specific folder', async () => { const violations = await (0, __1.metrics)(tsConfigPath) .inFolder('src/metrics/fluentapi') .lcom() .lcom96a() .shouldBeBelow(1.0) .check(); // Should pass if the specific folder exists expect(violations.length).toBeGreaterThanOrEqual(0); }); }); describe('Method chaining', () => { it('should support chaining multiple pattern matching methods', async () => { const violations = await (0, __1.metrics)(tsConfigPath) .inFolder('**/metrics') .withName('*.ts') .lcom() .lcom96a() .shouldBeBelow(1.0) .check(); // Should pass when combining folder and filename filters expect(violations.length).toBeGreaterThanOrEqual(0); }); it('should support mixing new and existing methods', async () => { const violations = await (0, __1.metrics)(tsConfigPath) .inPath('**/metrics/**') .forClassesMatching(/.*Builder/) .lcom() .lcom96a() .shouldBeBelow(1.0) .check(); // Should pass when combining path filter with class name filter expect(violations.length).toBeGreaterThanOrEqual(0); }); }); describe('Backwards compatibility', () => { it('should maintain existing inFile() functionality', async () => { const rule = (0, __1.metrics)(tsConfigPath) .inFolder('test/metrics/**') .lcom() .lcom96a() .shouldBeBelow(1.0); await expect(rule).toPassAsync(); }); it('should maintain existing forClassesMatching() functionality', async () => { const violations = await (0, __1.metrics)(tsConfigPath) .forClassesMatching(/.*Builder/) .lcom() .lcom96a() .shouldBeBelow(1.0) .check(); // Should pass if Builder classes exist expect(violations.length).toBeGreaterThanOrEqual(0); }); }); describe('Pattern matching with count metrics', () => { it('should work with count metrics', async () => { const violations = await (0, __1.metrics)(tsConfigPath) .withName('*.ts') .count() .methodCount() .shouldBeBelow(100) .check(); // Should pass with reasonable method count threshold expect(violations.length).toBeGreaterThanOrEqual(0); }); }); }); //# sourceMappingURL=pattern-matching-integration.spec.js.map