rofrischmann/react-look

View on GitHub
packages/react-look/test/plugins/fallbackValue-test.js

Summary

Maintainability
A
2 hrs
Test Coverage
import fallbackValue from '../../modules/plugins/fallbackValue'
import { resolver } from 'react-look-core'
const { resolvePlugins } = resolver


describe('Resolving fallback values', () => {
  it('should concat fallback values', () => {
    expect(fallbackValue({
      styles: {
        display: [ '-webkit-flex', 'flex' ]
      }
    })).to.eql({ display: '-webkit-flex;display:flex' })
  })

  it('should use param-case', () => {
    expect(fallbackValue({
      styles: {
        fallbackValues: [ 'value1', 'value2' ]
      }
    })).to.eql({ fallbackValues: 'value1;fallback-values:value2' })
  })

  it('should resolve nested objects', () => {
    expect(fallbackValue({
      styles: {
        fallbackValues: {
          property: [ 'value1', 'value2' ]
        }
      },
      config: {
        plugins: [ fallbackValue ]
      },
      resolve: resolvePlugins
    })).to.eql({
      fallbackValues: {
        property: 'value1;property:value2'
      }
    })
  })
})