-
-
Notifications
You must be signed in to change notification settings - Fork 196
Expand file tree
/
Copy pathtypegen-typescript.test.ts
More file actions
27 lines (21 loc) · 905 Bytes
/
typegen-typescript.test.ts
File metadata and controls
27 lines (21 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { expect, test, describe } from 'vitest'
import { pgTypeToTsType } from '../../src/server/templates/typescript.js'
const mockSchema = { id: 1, name: 'public' } as any
const mockContext = { types: [], schemas: [], tables: [], views: [] }
describe('pgTypeToTsType', () => {
test('maps vector to number[]', () => {
expect(pgTypeToTsType(mockSchema, 'vector', mockContext)).toBe('number[]')
})
test('maps _vector to (number[])[]', () => {
expect(pgTypeToTsType(mockSchema, '_vector', mockContext)).toBe('(number[])[]')
})
test('maps text to string', () => {
expect(pgTypeToTsType(mockSchema, 'text', mockContext)).toBe('string')
})
test('maps bool to boolean', () => {
expect(pgTypeToTsType(mockSchema, 'bool', mockContext)).toBe('boolean')
})
test('maps int4 to number', () => {
expect(pgTypeToTsType(mockSchema, 'int4', mockContext)).toBe('number')
})
})