@@ -300,6 +300,10 @@ describe('Prisma generator test', () => {
300300        await  getDMMF ( {  datamodel : content  } ) ; 
301301        expect ( content ) . toContain ( '@map("myGuardField")' ) ; 
302302        expect ( content ) . toContain ( '@map("myTransactionField")' ) ; 
303+         expect ( content ) . toContain ( 'value Int\n\n    zenstack_guard' ) ; 
304+         expect ( content ) . toContain ( 
305+             'zenstack_transaction String? @map("myTransactionField")\n\n    @@index([zenstack_transaction])' 
306+         ) ; 
303307    } ) ; 
304308
305309    it ( 'abstract multi files' ,  async  ( )  =>  { 
@@ -328,4 +332,34 @@ describe('Prisma generator test', () => {
328332        const  todo  =  dmmf . datamodel . models . find ( ( m )  =>  m . name  ===  'Todo' ) ; 
329333        expect ( todo ?. documentation ?. replace ( / \s / g,  '' ) ) . toBe ( `@@allow('read', owner == auth())` . replace ( / \s / g,  '' ) ) ; 
330334    } ) ; 
335+ 
336+     it ( 'format prisma' ,  async  ( )  =>  { 
337+         const  model  =  await  loadModel ( ` 
338+             datasource db { 
339+                 provider = 'postgresql' 
340+                 url = env('URL') 
341+             } 
342+ 
343+             model Post { 
344+                 id Int @id() @default(autoincrement()) 
345+                 title String 
346+                 content String? 
347+                 published Boolean @default(false) 
348+                 @@allow('read', published) 
349+             } 
350+         ` ) ; 
351+ 
352+         const  {  name }  =  tmp . fileSync ( {  postfix : '.prisma'  } ) ; 
353+         await  new  PrismaSchemaGenerator ( ) . generate ( model ,  { 
354+             provider : '@core/prisma' , 
355+             schemaPath : 'schema.zmodel' , 
356+             output : name , 
357+             format : true , 
358+         } ) ; 
359+ 
360+         const  content  =  fs . readFileSync ( name ,  'utf-8' ) ; 
361+         const  expected  =  fs . readFileSync ( path . join ( __dirname ,  './prisma/format.prisma' ) ,  'utf-8' ) ; 
362+ 
363+         expect ( content ) . toBe ( expected ) ; 
364+     } ) ; 
331365} ) ; 
0 commit comments