Skip to content

Commit bf0650b

Browse files
committed
chore: fix tests
1 parent 4fef058 commit bf0650b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

test/returns.test-d.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ const postgrest = new PostgrestClient<Database>(REST_URL)
3535
expectType<TypeEqual<typeof maybeSingleResultType, typeof maybeSingleExpected>>(true)
3636

3737
// Test array to non-array type casting error
38-
const invalidCastArray = (await postgrest.from('users').select().returns<{ username: string }>())
39-
.data
40-
expectType<typeof invalidCastArray>({
41-
Error:
42-
'Type mismatch: Cannot cast array result to a single object. Use .returns<Array<YourType>> for array results or .single() to convert the result to a single object',
43-
})
38+
const invalidCastArray = await postgrest.from('users').select().returns<{ username: string }>()
39+
if (invalidCastArray.error) {
40+
throw new Error(invalidCastArray.error.message)
41+
}
42+
let resultType: typeof invalidCastArray.data
43+
let resultExpected: {
44+
Error: 'Type mismatch: Cannot cast array result to a single object. Use .returns<Array<YourType>> for array results or .single() to convert the result to a single object'
45+
}
46+
expectType<TypeEqual<typeof resultType, typeof resultExpected>>(true)
4447

4548
// Test non-array to array type casting error
4649
const invalidCastSingle = postgrest

0 commit comments

Comments
 (0)