import { getTestClient } from '../../../../utils/getTestClient' ; let prisma ; describe ( 'groupBy' , ( ) => { beforeAll ( async ( ) => { const PrismaClient = await getTestClient ( ) ; prisma = new PrismaClient ( ) ; } ) ; afterAll ( async ( ) => { await prisma . $disconnect ( ) ; } ) ; test ( 'email' , async ( ) => { const user = await prisma . user . groupBy ( { by : [ 'email' ] , } ) ; expect ( user ) . toMatchSnapshot ( ) ; } ) ; test ( 'name' , async ( ) => { const user = await prisma . user . groupBy ( { by : [ 'name' ] , } ) ; expect ( user ) . toMatchSnapshot ( ) ; } ) ; test ( '2 fields' , async ( ) => { const user = await prisma . user . groupBy ( { by : [ 'email' , 'name' ] , } ) ; expect ( user ) . toMatchSnapshot ( ) ; } ) ; test ( 'count field and aggregations' , async ( ) => { const user = await prisma . user . groupBy ( { by : [ 'count' ] , where : { age : { gt : - 1 , } , } , _count : true , _min : { min : true , } , } ) ; expect ( user ) . toMatchSnapshot ( ) ; } ) ; test ( 'by  [name, count, min, sum, max, avg] with aggregations' , async ( ) => { const user = await prisma . user . groupBy ( { by : [ 'name' , 'count' , 'min' , 'sum' , 'max' , 'avg' ] , where : { age : { gt : - 1 , } , } , _count : true , _min : { min : true , } , } ) ; expect ( user ) . toMatchSnapshot ( ) ; } ) ; test ( 'name and aggregations' , async ( ) => { const user = await prisma . user . groupBy ( { by : [ 'name' ] , where : { age : { gt : - 1 , } , } , _avg : { age : true , } , _count : { age : true , _all : true , } , _max : { age : true , } , _min : { age : true , } , _sum : { age : true , } , } ) ; expect ( user ) . toMatchSnapshot ( ) ; } ) ; test ( 'name and with count' , async ( ) => { const user = await prisma . user . groupBy ( { by : [ 'name' ] , _count : true , } ) ; expect ( user ) . toMatchInlineSnapshot ( `
      Array [
        Object {
          _count: 10,
          name: Bobby Brown,
        },
      ]
    ` ) ; } ) ; } ) ;