Skip to content

Commit 31fe507

Browse files
committed
add test to ensure separation of concerns
1 parent e101db3 commit 31fe507

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { describe, expect, test } from 'vitest'
2+
import { filesOfProject } from 'tsarch'
3+
import fs from 'node:fs'
4+
import path from 'node:path'
5+
6+
describe('Ensure separation of concerns', () => {
7+
test('check language-internal dependencies', async () => {
8+
const langFolders = fs.readdirSync(path.join(__dirname, '..', '..', 'src', 'language'), { withFileTypes: true })
9+
.filter(file => file.isDirectory() && file.name !== 'generated')
10+
.map(file => path.join('language', file.name))
11+
12+
for (const sourceFolder of langFolders) {
13+
const ruleBuilder = filesOfProject()
14+
.inFolder(sourceFolder)
15+
.shouldNot()
16+
.dependOnFiles()
17+
18+
19+
for (const objectFolder of langFolders.filter(folder => folder !== sourceFolder)) {
20+
const rule = ruleBuilder.inFolder(objectFolder)
21+
22+
const violations = await rule.check()
23+
expect(violations, `expect ${sourceFolder} not to depend on ${objectFolder}`).toHaveLength(0)
24+
}
25+
}
26+
})
27+
})

0 commit comments

Comments
 (0)