import virtualBackgroundReducer, {
  clearCurrentVirtualBackground,
  setCurrentVirtualBackground,
} from './virtualBackgroundSlice'
import { VirtualBackgroundType } from '@zocks-communications/client-sdk-js'

test('sets the current virtual background', () => {
  const state = {
    currentVirtualBackground: null,
    availableVirtualBackgrounds: [{ type: VirtualBackgroundType.BLUR }],
    selectedVirtualBackground: null,
  }

  expect(
    virtualBackgroundReducer(state, setCurrentVirtualBackground({ type: VirtualBackgroundType.BLUR }))
  ).toStrictEqual({
    availableVirtualBackgrounds: [{ type: VirtualBackgroundType.BLUR }],
    currentVirtualBackground: { type: VirtualBackgroundType.BLUR },
    selectedVirtualBackground: null,
  })
})

test('clears the current virtual background', () => {
  const state = {
    currentVirtualBackground: { type: VirtualBackgroundType.BLUR },
    availableVirtualBackgrounds: [{ type: VirtualBackgroundType.BLUR }],
  }

  expect(virtualBackgroundReducer(state, clearCurrentVirtualBackground())).toStrictEqual({
    availableVirtualBackgrounds: [{ type: VirtualBackgroundType.BLUR }],
    currentVirtualBackground: null,
  })
})
