-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow architecture diagrams to support any character for titles
- Loading branch information
Showing
3 changed files
with
84 additions
and
6 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
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,68 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { Architecture } from '../src/index.js'; | ||
import { expectNoErrorsOrAlternatives, architectureParse as parse } from './test-util.js'; | ||
|
||
describe('architecture', () => { | ||
it.each([ | ||
`architecture-beta`, | ||
` architecture-beta `, | ||
`\tarchitecture-beta\t`, | ||
` | ||
\tarchitecture-beta | ||
`, | ||
])('should handle regular architecture-beta', (context: string) => { | ||
const result = parse(context); | ||
expectNoErrorsOrAlternatives(result); | ||
expect(result.value.$type).toBe(Architecture); | ||
}); | ||
|
||
it.each([ | ||
`architecture-beta group api(cloud)[API]`, | ||
` architecture-beta group api(cloud)[API] `, | ||
`\tarchitecture-beta\tgroup api(cloud)[API]\t`, | ||
` | ||
architecture-beta\tgroup api(cloud)[API] | ||
`, | ||
])('should handle architecture-beta & group in same line', (context: string) => { | ||
const result = parse(context); | ||
expectNoErrorsOrAlternatives(result); | ||
expect(result.value.$type).toBe(Architecture); | ||
|
||
const { groups } = result.value; | ||
expect(groups[0]).toBeTruthy(); | ||
}); | ||
|
||
it.each([ | ||
`architecture-beta | ||
group api(cloud)[API]`, | ||
`architecture-beta | ||
group api(cloud)[API] | ||
`, | ||
`architecture-beta | ||
group api(cloud)[API]`, | ||
`architecture-beta | ||
group api(cloud)[API] | ||
`, | ||
])('should handle architecture-beta + group in different line', (context: string) => { | ||
const result = parse(context); | ||
expectNoErrorsOrAlternatives(result); | ||
expect(result.value.$type).toBe(Architecture); | ||
|
||
const { groups } = result.value; | ||
expect(groups[0].title).toBe('API'); | ||
}); | ||
|
||
it.each([ | ||
`architecture-beta group api(cloud)[a.b-t]`, | ||
`architecture-beta group api(cloud)[user:password@some_domain.com] | ||
`, | ||
])('should handle special character in a title', (context: string) => { | ||
const result = parse(context); | ||
expectNoErrorsOrAlternatives(result); | ||
expect(result.value.$type).toBe(Architecture); | ||
|
||
const { groups } = result.value; | ||
expect(groups[0]).toBeTruthy(); | ||
}); | ||
}); |
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