import { getClassName, getMergedClassNames } from './utils'

test('getMergedClassNames returns first object if second is empty', () => {
  const styles1 = {
    class_one: 'module_classOne',
  }
  const result = getMergedClassNames(styles1, undefined)
  expect(result).toEqual(styles1)
})

test('getMergedClassNames returns merged objects', () => {
  const styles1 = {
    class_one: 'module_classOne',
  }
  const styles2 = {
    class_two: 'module_classTwo',
  }
  const result = getMergedClassNames(styles1, styles2)
  expect(result).toEqual({ ...styles1, ...styles2 })
})

test('getMergedClassNames returns merged objects with merged class names on the same key', () => {
  const styles1 = {
    class_one: 'module_classOne',
  }
  const styles2 = {
    class_one: 'module2_classOne',
    class_two: 'module_classTwo',
  }
  const result = getMergedClassNames(styles1, styles2)
  expect(result).toEqual({ class_one: 'module_classOne module2_classOne', class_two: 'module_classTwo' })
})

test('getClassName returns className from classNames object and zocks prefixed class name too', () => {
  const styles1 = {
    class_one: 'module_classOne',
  }
  const result = getClassName('class_one', styles1)
  expect(result).toEqual('module_classOne zocks__class_one')
})

test('getClassName returns zocks prefixed class name only if classname not present in the given object', () => {
  const styles1 = {
    class_one: 'module_classOne',
  }
  const result = getClassName('class_two', styles1)
  expect(result).toEqual('zocks__class_two')
})
