1+ /* eslint-disable @typescript-eslint/unbound-method */
12import { Hub , Scope } from '@sentry/hub' ;
23
34import { Prisma } from '../../../src/integrations/node/prisma' ;
@@ -6,30 +7,30 @@ import { Span } from '../../../src/span';
67type PrismaMiddleware = ( params : unknown , next : ( params ?: unknown ) => Promise < unknown > ) => Promise < unknown > ;
78
89class PrismaClient {
10+ public user : { create : ( ) => Promise < unknown > } = {
11+ create : ( ) => this . _middleware ?.( { action : 'create' , model : 'user' } , ( ) => Promise . resolve ( 'result' ) ) ,
12+ } ;
13+
14+ private _middleware ?: PrismaMiddleware ;
15+
916 constructor ( ) {
10- this . middleware = undefined ;
17+ this . _middleware = undefined ;
1118 }
1219
13- private middleware ?: PrismaMiddleware ;
14-
1520 public $use ( cb : PrismaMiddleware ) {
16- this . middleware = cb ;
21+ this . _middleware = cb ;
1722 }
18-
19- public user = {
20- create : ( ) => this . middleware ?.( { action : 'create' , model : 'user' } , ( ) => Promise . resolve ( 'result' ) ) ,
21- } ;
2223}
2324
24- describe ( 'setupOnce' , ( ) => {
25+ describe ( 'setupOnce' , function ( ) {
2526 const Client : PrismaClient = new PrismaClient ( ) ;
2627
2728 let scope = new Scope ( ) ;
2829 let parentSpan : Span ;
2930 let childSpan : Span ;
3031
3132 beforeAll ( ( ) => {
32- // @ts -ignore
33+ // @ts -ignore, not to export PrismaClient types from integration source
3334 new Prisma ( { client : Client } ) . setupOnce (
3435 ( ) => undefined ,
3536 ( ) => new Hub ( undefined , scope ) ,
@@ -45,8 +46,8 @@ describe('setupOnce', () => {
4546 jest . spyOn ( childSpan , 'finish' ) ;
4647 } ) ;
4748
48- it ( ` should add middleware with $use method correctly` , done => {
49- Client . user . create ( ) ?. then ( res => {
49+ it ( ' should add middleware with $use method correctly' , done => {
50+ void Client . user . create ( ) ?. then ( res => {
5051 expect ( res ) . toBe ( 'result' ) ;
5152 expect ( scope . getSpan ) . toBeCalled ( ) ;
5253 expect ( parentSpan . startChild ) . toBeCalledWith ( {
0 commit comments