1import { describe, expect, it } from 'vitest'2import { lowerC4 } from '../src/adapters/c4-lowerer'34describe('C4 bounded lowering', () => {5 it('preserves entity semantics, relationships, technology, and local include aliases', () => {6 const lowered = lowerC4(`@startuml7!include C4_Context.puml8Person_Ext(user, "User")9System_Ext(mail, "Mail service")10System(app, "App")11Rel_Back(app, mail, "sends", "SMTP")12Rel_Neighbor(user, app, "uses")13SHOW_LEGEND()14@enduml`)1516 expect(lowered).toContain('person "User" as user')17 expect(lowered).toContain('#686868')18 expect(lowered).toContain('rectangle "Mail service" as mail')19 expect(lowered).toContain('#999999')20 expect(lowered).toContain('app <-- mail : sends [SMTP]')21 expect(lowered).toContain('user .. app : uses')22 expect(lowered).toContain('C4-PlantUML')23 expect(lowered).not.toContain('!include')24 })2526 it('rejects unknown C4-shaped calls rather than passing broken source through', () => {27 expect(() => lowerC4('@startuml\nUnknownC4Macro(foo)\n@enduml')).toThrow(/Unsupported C4 macro/)28 })2930 it('bounds aliases, tags, and multiline text before generating PlantUML', () => {31 expect(() => lowerC4('@startuml\nSystem(bad-alias, "App")\n@enduml')).toThrow(/invalid alias/)32 expect(() => lowerC4('@startuml\nSystem(app, "App", "", "", "bad>>tag")\n@enduml')).toThrow(/C4 tags/)33 expect(lowerC4('@startuml\nSystem(app, "First\\nSecond")\n@enduml')).toContain('"First\\nSecond" as app')34 })3536 it('keeps container and component technology, descriptions, and tags in their C4 argument positions', () => {37 const lowered = lowerC4('@startuml\nContainer(api, "API", "Node.js", "Serves calls", "", "backend")\n@enduml')38 expect(lowered).toContain('"API\\n[Node.js]\\n[Serves calls]" as api')39 expect(lowered).toContain('<<c4-container,backend>>')40 })41})