-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy patharchitecture.spec.ts
More file actions
63 lines (55 loc) · 1.7 KB
/
Copy patharchitecture.spec.ts
File metadata and controls
63 lines (55 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import type { FileConditionBuilder } from 'tsarch'
import { resolve } from 'node:path'
import { filesOfProject } from 'tsarch'
import { beforeAll, describe, expect, test } from 'vitest'
describe('Architectural checks', () => {
let files: FileConditionBuilder
beforeAll(() => {
files = filesOfProject(resolve(__dirname, 'tsconfig.json'))
})
test('POLAR should be cycle-free', async () => {
const violations = await files
.matchingPattern('.*')
.should()
.beFreeOfCycles()
.check()
expect(violations).toEqual([])
})
test('Core should not depend on plugins (except for plugin types)', async () => {
const violations = await files
.matchingPattern('^core/(?!types/.*\\.ts$).*$')
.shouldNot()
.dependOnFiles()
.matchingPattern('^plugins/.*$')
.check()
expect(violations).toEqual([])
})
test('Plugin file structure', async () => {
const violations = await files
.matchingPattern('^plugins/.*$')
.should()
.matchPattern(
'^plugins/[^/]+/((index|locales|store|types)\\.ts|utils/.*\\.ts|components/.*\\.spec\\.ts|stores/.*\\.ts|composables/.*\\.ts)$'
)
.check()
expect(violations).toEqual([])
})
test('Plugins should only depend on public core API', async () => {
const violations = await files
.matchingPattern('^plugins/.*$')
.shouldNot()
.dependOnFiles()
.matchingPattern('^core/(?!(index|stores/index)\\.ts$).*$')
.check()
expect(violations).toEqual([])
})
test('Lib utils should only depend on public core API', async () => {
const violations = await files
.matchingPattern('^lib/.*$')
.shouldNot()
.dependOnFiles()
.matchingPattern('^core/(?!(index|stores/index)\\.ts$).*$')
.check()
expect(violations).toEqual([])
})
})