import {createStore, mountComposition} from "~/tests/unit/Helpers";
import {accessProfile as accessModule} from "~/tests/unit/fixture/state/profile";
import {AccessStore} from "~/types/interfaces";
import {UseAccess} from "~/composables/utils/useAccess";

let store:AccessStore
let useAccessMount:any

beforeAll(() => {
  store = createStore()
  store.registerModule('profile', {})
  store.registerModule(['profile', 'access'], accessModule)

  const component = mountComposition(() => {
    useAccessMount = UseAccess(store)
  });
})

describe('hasMenuOrIsTeacher()', () => {
  it('must to return false', () => {
    const {hasMenuOrIsTeacher} = useAccessMount
    expect(hasMenuOrIsTeacher.value).toBeFalsy()
  })

  it('must to return true because user have a lateral menu', () => {
    store.commit('profile/access/setHasLateralMenu', true)
    const {hasMenuOrIsTeacher} = useAccessMount
    expect(hasMenuOrIsTeacher.value).toBeFalsy()
  })

  it('must to return true because user is a teacher', () => {
    store.commit('profile/access/setHasLateralMenu', false)
    store.commit('profile/access/setIsTeacher', true)
    const {hasMenuOrIsTeacher} = useAccessMount
    expect(hasMenuOrIsTeacher.value).toBeFalsy()
  })
})
