1
1
import { it , describe , expect } from 'vitest' ;
2
- import { db } from './architectureDb.js' ;
3
2
import { parser } from './architectureParser.js' ;
4
-
5
- const {
6
- clear,
7
- getDiagramTitle,
8
- getAccTitle,
9
- getAccDescription,
10
- getServices,
11
- getGroups,
12
- getEdges,
13
- getJunctions,
14
- } = db ;
15
-
3
+ import { ArchitectureDB } from './architectureDb.js' ;
16
4
describe ( 'architecture diagrams' , ( ) => {
5
+ let db : ArchitectureDB ;
17
6
beforeEach ( ( ) => {
18
- clear ( ) ;
7
+ db = new ArchitectureDB ( ) ;
8
+ // @ts -expect-error since type is set to undefined we will have error
9
+ parser . parser ?. yy = db ;
19
10
} ) ;
20
11
21
12
describe ( 'architecture diagram definitions' , ( ) => {
@@ -36,15 +27,15 @@ describe('architecture diagrams', () => {
36
27
it ( 'should handle title on the first line' , async ( ) => {
37
28
const str = `architecture-beta title Simple Architecture Diagram` ;
38
29
await expect ( parser . parse ( str ) ) . resolves . not . toThrow ( ) ;
39
- expect ( getDiagramTitle ( ) ) . toBe ( 'Simple Architecture Diagram' ) ;
30
+ expect ( db . getDiagramTitle ( ) ) . toBe ( 'Simple Architecture Diagram' ) ;
40
31
} ) ;
41
32
42
33
it ( 'should handle title on another line' , async ( ) => {
43
34
const str = `architecture-beta
44
35
title Simple Architecture Diagram
45
36
` ;
46
37
await expect ( parser . parse ( str ) ) . resolves . not . toThrow ( ) ;
47
- expect ( getDiagramTitle ( ) ) . toBe ( 'Simple Architecture Diagram' ) ;
38
+ expect ( db . getDiagramTitle ( ) ) . toBe ( 'Simple Architecture Diagram' ) ;
48
39
} ) ;
49
40
50
41
it ( 'should handle accessibility title and description' , async ( ) => {
@@ -53,8 +44,8 @@ describe('architecture diagrams', () => {
53
44
accDescr: Accessibility Description
54
45
` ;
55
46
await expect ( parser . parse ( str ) ) . resolves . not . toThrow ( ) ;
56
- expect ( getAccTitle ( ) ) . toBe ( 'Accessibility Title' ) ;
57
- expect ( getAccDescription ( ) ) . toBe ( 'Accessibility Description' ) ;
47
+ expect ( db . getAccTitle ( ) ) . toBe ( 'Accessibility Title' ) ;
48
+ expect ( db . getAccDescription ( ) ) . toBe ( 'Accessibility Description' ) ;
58
49
} ) ;
59
50
60
51
it ( 'should handle multiline accessibility description' , async ( ) => {
@@ -64,7 +55,7 @@ describe('architecture diagrams', () => {
64
55
}
65
56
` ;
66
57
await expect ( parser . parse ( str ) ) . resolves . not . toThrow ( ) ;
67
- expect ( getAccDescription ( ) ) . toBe ( 'Accessibility Description' ) ;
58
+ expect ( db . getAccDescription ( ) ) . toBe ( 'Accessibility Description' ) ;
68
59
} ) ;
69
60
} ) ;
70
61
} ) ;
0 commit comments