import type { Match } from 'requests'

import { getMatchAccess, MatchAccess } from '..'

type Args = {
  access?: boolean,
  calc?: boolean,
  has_video?: boolean,
  live?: boolean,
  storage?: boolean,
  sub?: boolean,
}

const createMatch = (args: Args) => ({
  ...args,
} as Match)

it('equals to no country access type', () => {
  const match = createMatch({
    access: false,
    sub: false,
  })

  expect(getMatchAccess(match)).toBe(MatchAccess.CanBuyMatch)
})

it('equals to  redirect type', () => {
  const match = createMatch({
    access: true,
    calc: false,
    has_video: true,
    sub: true,
  })

  expect(getMatchAccess(match)).toBe(MatchAccess.RedirectToProfile)
})

it('equals to  can buy type', () => {
  const match = createMatch({
    access: true,
    sub: false,
  })

  expect(getMatchAccess(match)).toBe(MatchAccess.CanBuyMatch)
})

it('equals to view match popup type', () => {
  let match = createMatch({
    access: true,
    live: true,
    sub: true,
  })

  expect(getMatchAccess(match)).toBe(MatchAccess.ViewMatchPopup)

  match = createMatch({
    access: true,
    calc: true,
    has_video: true,
    live: false,
    sub: true,
  })

  expect(getMatchAccess(match)).toBe(MatchAccess.RedirectToProfile)

  match = createMatch({
    access: true,
    calc: true,
    has_video: false,
    live: false,
    storage: true,
    sub: true,
  })

  expect(getMatchAccess(match)).toBe(MatchAccess.RedirectToProfile)
})
