-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
247 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"showImportsWarning": false, | ||
"failOnEmptyShould": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { RelativePath } from "arch-unit-ts/dist/arch-unit/core/domain/RelativePath"; | ||
import { TypeScriptProject } from "arch-unit-ts/dist/arch-unit/core/domain/TypeScriptProject"; | ||
import { classes, noClasses } from "arch-unit-ts/dist/main"; | ||
import { Architectures } from "arch-unit-ts/dist/arch-unit/library/Architectures"; | ||
import { AdminModule } from "src/admin/Admin.module"; | ||
describe("Architecture test", () => { | ||
const srcProject = new TypeScriptProject(RelativePath.of("src")); | ||
|
||
describe("Application", () => { | ||
it("Should not depend on infrastructure", () => { | ||
noClasses() | ||
.that() | ||
.resideInAPackage("..core..") | ||
.should() | ||
.dependOnClassesThat() | ||
.resideInAnyPackage("..infra..") | ||
.because("core should not depend on infrastructure") | ||
.check(srcProject.allClasses()); | ||
}); | ||
it("Should only have few dependencies", () => { | ||
classes() | ||
.that() | ||
.resideInAPackage("..core..") | ||
.should() | ||
.onlyDependOnClassesThat() | ||
.resideInAnyPackage("packages", "core", "@nestjs.common", "@nestjs.testing") | ||
.because("Core should not depend on any other dependencies") | ||
.check(srcProject.allClasses()); | ||
}); | ||
}); | ||
|
||
describe("Admin", () => { | ||
it("Should implement an hexagonal architecture", async () => { | ||
Architectures.layeredArchitecture() | ||
.consideringOnlyDependenciesInAnyPackage("src.admin.core..", "src.admin.infra..") | ||
.layer("useCase", "src.admin..core..useCase..") | ||
.layer("repository", "src.admin..infra..repository..") | ||
.layer("infra", "src.admin..infra..") | ||
.layer("core", "src.admin..core..") | ||
.whereLayer("useCase") | ||
.mayOnlyBeAccessedByLayers("infra", "useCase") | ||
.whereLayer("repository") | ||
.mayOnlyBeAccessedByLayers("infra") | ||
.whereLayer("infra") | ||
.mayNotBeAccessedByAnyLayer() | ||
.because("Each bounded context should implement an hexagonal architecture") | ||
.check(srcProject.allClasses()); | ||
}); | ||
it("Should depend on specific dependencies", async () => { | ||
classes() | ||
.that() | ||
.resideInAPackage("..admin.core..") | ||
.should() | ||
.onlyDependOnClassesThat() | ||
.resideInAnyPackage( | ||
"packages", | ||
"notification..core", | ||
"shared..core", | ||
"admin..core", | ||
"@nestjs.common", | ||
"@nestjs.testing", | ||
) | ||
.because("Core should not depend on any other dependencies") | ||
.check(srcProject.allClasses()); | ||
}); | ||
}); | ||
|
||
describe("Shared", () => { | ||
it("Should depend on specific dependencies", async () => { | ||
classes() | ||
.that() | ||
.resideInAPackage("..shared.core..") | ||
.should() | ||
.onlyDependOnClassesThat() | ||
.resideInAnyPackage("shared..core", "@nestjs.common") | ||
.because("Core should not depend on any other dependencies") | ||
.check(srcProject.allClasses()); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.