import { mapTranslationsToLocalKeys } from '..'

const createTranslation = (id: string) => ({
  id,
  lang: '',
  lexis_lang_id: '',
  text: '',
})

it('returns empty object for empty args', () => {
  const translations = {}
  const config = {}
  const expected = {}

  const result = mapTranslationsToLocalKeys(translations, config)
  expect(result).toEqual(expected)
})

it('empty translations when config is empty', () => {
  const translations = { 1: createTranslation('1') }
  const lexicsConfig = {}
  const expected = {}

  const result = mapTranslationsToLocalKeys(translations, lexicsConfig)
  expect(result).toEqual(expected)
})

it('translations with lexic key specified in config', () => {
  const translations = { 1: createTranslation('1'), 2: createTranslation('2') }
  const lexicsConfig = { 2: 2, formInput: 1 }
  const expected = { 2: translations[2], formInput: translations[1] }

  const result = mapTranslationsToLocalKeys(translations, lexicsConfig)
  expect(result).toEqual(expected)
})
