import configurePlugins from '../src/util/configurePlugins'

test('setting a plugin to false removes it', () => {
  const plugins = {
    fontSize: (options) => {
      return {
        plugin: 'fontSize',
        options,
      }
    },
    display: (options) => {
      return {
        plugin: 'display',
        options,
      }
    },
    backgroundPosition: (options) => {
      return {
        plugin: 'backgroundPosition',
        options,
      }
    },
  }

  const configuredPlugins = configurePlugins(plugins, {
    fontSize: {},
    display: false,
    backgroundPosition: {},
  })

  expect(configuredPlugins).toEqual([
    { plugin: 'fontSize', options: {} },
    { plugin: 'backgroundPosition', options: {} },
  ])
})

import configurePlugins from '../src/util/configurePlugins'

test('setting a plugin to false removes it', () => {
  const plugins = {
    fontSize: (options) => {
      return {
        plugin: 'fontSize',
        options,
      }
    },
    display: (options) => {
      return {
        plugin: 'display',
        options,
      }
    },
    backgroundPosition: (options) => {
      return {
        plugin: 'backgroundPosition',
        options,
      }
    },
  }

  const configuredPlugins = configurePlugins(plugins, {
    fontSize: {},
    display: false,
    backgroundPosition: {},
  })

  expect(configuredPlugins).toEqual([
    { plugin: 'fontSize', options: {} },
    { plugin: 'backgroundPosition', options: {} },
  ])
})

test('setting a plugin to an object configures that plugin', () => {
  const plugins = {
    fontSize: (options) => {
      return {
        plugin: 'fontSize',
        options,
      }
    },
    display: (options) => {
      return {
        plugin: 'display',
        options,
      }
    },
    backgroundPosition: (options) => {
      return {
        plugin: 'backgroundPosition',
        options,
      }
    },
  }

  const configuredPlugins = configurePlugins(plugins, {
    fontSize: { variants: ['responsive', 'hover'], values: { '12': '12px', '14': '14px', '16': '16px', } },
    display: { variants: ['responsive'] },
    backgroundPosition: {},
  })

  expect(configuredPlugins).toEqual([
    { plugin: 'fontSize', options: { variants: ['responsive', 'hover'], values: { '12': '12px', '14': '14px', '16': '16px', } } },
    { plugin: 'display', options: { variants: ['responsive'] } },
    { plugin: 'backgroundPosition', options: {} },
  ])
})

Test overriding a core plugin's config