@@ -2,7 +2,10 @@ import type {
22 AnyDatabaseNotification ,
33 DatabaseNotification ,
44} from 'vintasend/dist/types/notification' ;
5- import type { NotificationFilter } from 'vintasend/dist/services/notification-backends/base-notification-backend' ;
5+ import type {
6+ NotificationFilter ,
7+ NotificationOrderBy ,
8+ } from 'vintasend/dist/services/notification-backends/base-notification-backend' ;
69import { PrismaNotificationBackendFactory } from '../index' ;
710import { NotificationStatusEnum , NotificationTypeEnum } from '../prisma-notification-backend' ;
811import type {
@@ -1442,6 +1445,33 @@ describe('PrismaNotificationBackend', () => {
14421445 take : 10 ,
14431446 } ) ;
14441447 } ) ;
1448+
1449+ it . each ( [
1450+ { field : 'sendAfter' , direction : 'asc' } ,
1451+ { field : 'sendAfter' , direction : 'desc' } ,
1452+ { field : 'sentAt' , direction : 'asc' } ,
1453+ { field : 'sentAt' , direction : 'desc' } ,
1454+ { field : 'readAt' , direction : 'asc' } ,
1455+ { field : 'readAt' , direction : 'desc' } ,
1456+ { field : 'createdAt' , direction : 'asc' } ,
1457+ { field : 'createdAt' , direction : 'desc' } ,
1458+ { field : 'updatedAt' , direction : 'asc' } ,
1459+ { field : 'updatedAt' , direction : 'desc' } ,
1460+ ] as NotificationOrderBy [ ] ) ( 'should map orderBy $field $direction into prisma findMany' , async ( orderBy ) => {
1461+ const findManyMock = mockPrismaClient . notification . findMany as jest . Mock ;
1462+ findManyMock . mockResolvedValue ( [ mockNotification ] ) ;
1463+
1464+ await backend . filterNotifications ( { } , 1 , 10 , orderBy ) ;
1465+
1466+ expect ( findManyMock ) . toHaveBeenCalledWith ( {
1467+ where : { } ,
1468+ orderBy : {
1469+ [ orderBy . field ] : orderBy . direction ,
1470+ } ,
1471+ skip : 10 ,
1472+ take : 10 ,
1473+ } ) ;
1474+ } ) ;
14451475 } ) ;
14461476
14471477 describe ( 'deserializeNotificationForUpdate' , ( ) => {
0 commit comments