mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
Fix misnamed bools, add date tests
This commit is contained in:
1 parent
f138634750
commit
def5010567
1 file changed
+17
-3
@@ -29,11 +29,11 @@ describe('SpreadsheedImport.utils: inferColumnType', () => {
|
||||
test('should infer boolean types correctly', () => {
|
||||
const mockData1 = [{ name: 'bob', height: '161.72', isWorking: 'true' }]
|
||||
const type1 = inferColumnType('isWorking', mockData1)
|
||||
expect(type1).toBe('boolean')
|
||||
expect(type1).toBe('bool')
|
||||
|
||||
const mockData2 = [{ name: 'bob', height: '161.72', isRetired: 'false' }]
|
||||
const type2 = inferColumnType('isRetired', mockData2)
|
||||
expect(type2).toBe('boolean')
|
||||
expect(type2).toBe('bool')
|
||||
})
|
||||
test('should infer boolean type for a supposed boolean column if one of the rows has a null value', () => {
|
||||
const mockData3 = [
|
||||
@@ -42,11 +42,25 @@ describe('SpreadsheedImport.utils: inferColumnType', () => {
|
||||
{ name: 'bob', height: '161.72', isRetired: null },
|
||||
]
|
||||
const type3 = inferColumnType('isRetired', mockData3)
|
||||
expect(type3).toBe('boolean')
|
||||
expect(type3).toBe('bool')
|
||||
})
|
||||
test('should infer objects as jsonb types correctly', () => {
|
||||
const mockData = [{ name: 'bob', metadata: '{}' }]
|
||||
const type = inferColumnType('metadata', mockData)
|
||||
expect(type).toBe('jsonb')
|
||||
})
|
||||
test.only('should infer date type correctly', () => {
|
||||
const mockData4 = [
|
||||
{ event: 'christmas', date: '2022-12-25 17:45:23 UTC' },
|
||||
{ event: 'christmas', date: '2022-12-25' },
|
||||
{ event: 'christmas', date: '2022-12-25T12:03:40Z' },
|
||||
{ event: 'christmas', date: new Date() },
|
||||
{ event: 'christmas', date: new Date().toISOString() },
|
||||
{ event: 'christmas', date: 1410715640579 },
|
||||
{ event: 'christmas', date: '25 Dec 2022' },
|
||||
{ event: 'christmas', date: 'Dec 25 2022' },
|
||||
]
|
||||
const type4 = inferColumnType('date', mockData4)
|
||||
expect(type4).toBe('timestamptz')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user