archunit
Version:
ArchUnit TypeScript is an architecture testing library, to specify and assert architecture rules in your TypeScript app
76 lines • 3.19 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
require("../index");
const path_1 = __importDefault(require("path"));
const slices_1 = require("../src/slices");
const files_1 = require("../src/files");
describe('architecture', () => {
it('components follow their inner architecture', async () => {
const diagramLocation = path_1.default.resolve('test', 'components_inner.puml');
const rules = ['common', 'files', 'slices', 'metrics'].map((c) => {
return (0, slices_1.projectSlices)()
.definedBy(`src/${c}/(**)/`)
.should()
.adhereToDiagramInFile(diagramLocation);
});
for (let i = 0; i < rules.length; i++) {
await expect(rules[i]).toPassAsync();
}
});
it('common should not depend on specific components', async () => {
for (const c of ['files', 'testing', 'slices']) {
const rule = (0, files_1.projectFiles)()
.inFolder('src/common/**')
.shouldNot()
.dependOnFiles()
.inFolder(`src/${c}/**`);
await expect(rule).toPassAsync();
}
});
it('files should not depend on forbidden components', async () => {
for (const c of ['slices', 'testing', 'metrics']) {
const rule = (0, files_1.projectFiles)()
.inFolder('src/files/**')
.shouldNot()
.dependOnFiles()
.inFolder(`src/${c}/**`);
await expect(rule).toPassAsync();
}
});
it('metrics should not depend on forbidden components', async () => {
for (const c of ['files', 'testing', 'slices']) {
const rule = (0, files_1.projectFiles)()
.inFolder('src/metrics/**')
.shouldNot()
.dependOnFiles()
.inFolder(`src/${c}/**`);
await expect(rule).toPassAsync();
}
});
it('slices should not depend on forbidden components', async () => {
for (const c of ['files', 'testing', 'metrics']) {
const rule = (0, files_1.projectFiles)()
.inFolder('src/slices/**')
.shouldNot()
.dependOnFiles()
.inFolder(`src/${c}/**`);
await expect(rule).toPassAsync();
}
});
// TODO: we need some refactoring, a few cycles occurred unfortunately
it.skip('code should be cycle free', async () => {
const arr = ['files', 'jest', 'metrics', 'slices', 'testing'];
for (const el of arr) {
const rule = (0, files_1.projectFiles)().inFolder(`src/${el}`).should().haveNoCycles();
await expect(rule).toPassAsync();
}
});
it.skip('should have the right naming convention for tests', async () => {
//const rule = projectFiles().inFolder('test').should().matchFilename('*.spec.ts');
//await expect(rule).toPassAsync();
});
});
//# sourceMappingURL=architecture.spec.js.map