import { HotColumnSettings } from '../models/dc-validation.model'
import { parseColTypeRow } from '../utils/parseColTypeRow'

describe('DC Validator - parse col type row', () => {
  it('parses a single JSON object', () => {
    const expected: HotColumnSettings = { data: 'test', type: 'numeric' }

    expect(parseColTypeRow('{"data":"test","type":"numeric"}')).toEqual(
      expected
    )
  })

  it('returns undefined for undefined input (LEFT JOIN can leave it unset)', () => {
    expect(parseColTypeRow(undefined)).toBeUndefined()
  })

  it('returns undefined for an empty string', () => {
    expect(parseColTypeRow('')).toBeUndefined()
  })

  it('returns undefined for malformed JSON, without throwing', () => {
    expect(parseColTypeRow('{not valid')).toBeUndefined()
  })
})
