@@ -5,11 +5,11 @@ import { mocked } from 'jest-mock'
5
5
import { ConnectionArguments , findManyCursorConnection } from '../src'
6
6
import { PROFILE_FIXTURES , TODO_FIXTURES , USER_FIXTURES } from './fixtures'
7
7
8
- function encodeCursor < Cursor > ( prismaCursor : Cursor ) {
8
+ function encodeCursor < Cursor > ( prismaCursor : Cursor ) : string {
9
9
return Buffer . from ( JSON . stringify ( prismaCursor ) ) . toString ( 'base64' )
10
10
}
11
11
12
- function decodeCursor ( cursor : string ) {
12
+ function decodeCursor < Cursor > ( cursor : string ) : Cursor {
13
13
return JSON . parse ( Buffer . from ( cursor , 'base64' ) . toString ( 'ascii' ) )
14
14
}
15
15
@@ -21,7 +21,7 @@ describe('prisma-relay-cursor-connection', () => {
21
21
jest . setTimeout ( 10000 )
22
22
let client : PrismaClient
23
23
24
- beforeAll ( async ( ) => {
24
+ beforeAll ( ( ) => {
25
25
client = new PrismaClient ( )
26
26
} )
27
27
@@ -89,22 +89,22 @@ describe('prisma-relay-cursor-connection', () => {
89
89
expect ( result ) . toMatchSnapshot ( )
90
90
91
91
// Test that the return types work via TS
92
- result . edges [ 0 ] . node . isCompleted
92
+ expect ( result . edges [ 0 ] . node . isCompleted )
93
93
94
94
// @ts -expect-error Typo in selected field
95
- result . edges [ 0 ] . node . isCompletedd
95
+ expect ( result . edges [ 0 ] . node . isCompletedd )
96
96
97
97
// @ts -expect-error Not selected field
98
- result . edges [ 0 ] . node . text
98
+ expect ( result . edges [ 0 ] . node . text )
99
99
100
100
// Test that the return types work via TS
101
- result . nodes [ 0 ] . isCompleted
101
+ expect ( result . nodes [ 0 ] . isCompleted )
102
102
103
103
// @ts -expect-error Typo in selected field
104
- result . nodes [ 0 ] . isCompletedd
104
+ expect ( result . nodes [ 0 ] . isCompletedd )
105
105
106
106
// @ts -expect-error Not selected field
107
- result . nodes [ 0 ] . text
107
+ expect ( result . nodes [ 0 ] . text )
108
108
} )
109
109
} )
110
110
@@ -200,22 +200,22 @@ describe('prisma-relay-cursor-connection', () => {
200
200
expect ( result ) . toMatchSnapshot ( )
201
201
202
202
// Test that the return types work via TS
203
- result . edges [ 0 ] . node . email
203
+ expect ( result . edges [ 0 ] . node . email )
204
204
205
205
// @ts -expect-error Typo in selected field
206
- result . edges [ 0 ] . node . emmail
206
+ expect ( result . edges [ 0 ] . node . emmail )
207
207
208
208
// @ts -expect-error Not selected field
209
- result . edges [ 0 ] . node . text
209
+ expect ( result . edges [ 0 ] . node . text )
210
210
211
211
// Test that the return types work via TS
212
- result . nodes [ 0 ] . email
212
+ expect ( result . nodes [ 0 ] . email )
213
213
214
214
// @ts -expect-error Typo in selected field
215
- result . nodes [ 0 ] . emmail
215
+ expect ( result . nodes [ 0 ] . emmail )
216
216
217
217
// @ts -expect-error Not selected field
218
- result . nodes [ 0 ] . text
218
+ expect ( result . nodes [ 0 ] . text )
219
219
} )
220
220
} )
221
221
@@ -469,13 +469,13 @@ describe('prisma-relay-cursor-connection', () => {
469
469
expect ( result ) . toMatchSnapshot ( )
470
470
471
471
// Test that the node.extraNodeField return types work via TS
472
- result . edges [ 0 ] ?. node . extraNodeField
472
+ expect ( result . edges [ 0 ] ?. node . extraNodeField )
473
473
474
474
// Test that the extraEdgeField return type work via TS
475
- result . edges [ 0 ] ?. extraEdgeField
475
+ expect ( result . edges [ 0 ] ?. extraEdgeField )
476
476
477
477
// Test that the node.extraNodeField return types work via TS
478
- result . nodes [ 0 ] ?. extraNodeField
478
+ expect ( result . nodes [ 0 ] ?. extraNodeField )
479
479
} )
480
480
} )
481
481
@@ -564,8 +564,7 @@ describe('prisma-relay-cursor-connection', () => {
564
564
} )
565
565
566
566
// These are not real tests which run, but rather a way to ensure that the types are correct
567
- // when tsc runs
568
- const typecheckForInferredTypes = async ( ) => {
567
+ export const typecheckForInferredTypes = async ( ) : Promise < void > => {
569
568
const client = new PrismaClient ( )
570
569
571
570
// Default will get the inferred types from prisma
@@ -610,5 +609,3 @@ const typecheckForInferredTypes = async () => {
610
609
} [ ]
611
610
}
612
611
}
613
-
614
- typecheckForInferredTypes
0 commit comments