import {expect, describe, test, beforeEach} from 'vitest'
import { createStore } from "vuex"
import { store as layout } from '@/store/modules/layout';

describe('test of layout store', () => {
  const store = createStore({
    modules: {
      layout
    }
  })

  beforeEach(() => {
    store.dispatch('layout/resetStore')
  })

  test('test layout store exist', async () => {
    expect(store).toBeTruthy()
    expect(store.getters['layout/isOpenedMobileMenu']).toBe(false)
    expect(store.getters['layout/isEnabledMenu']).toBe(true)
  })

  test('test toggleMenu', () => {
    store.dispatch('layout/toggleMenu')
    const result = store.getters['layout/isShowMenu']
    expect(result).toBe(false)
  })

  test('test setIsShowMenu', () => {
    store.dispatch('layout/setIsShowMenu', false)
    const result = store.getters['layout/isShowMenu']
    expect(result).toBe(false)
  })

  test('test setIsMobileMenuOpened', () => {
    store.dispatch('layout/setIsMobileMenuOpened', true)
    const result = store.getters['layout/isOpenedMobileMenu']
    expect(result).toBe(true)
  })

  test('test resetStore', () => {
    store.dispatch('layout/resetStore')
    const result = store.getters['layout/isShowMenu']
    expect(result).toBe(true)
  })

  test('test initScreenSizeListener', () => {
    store.dispatch('layout/initScreenSizeListener')
    const result = store.getters['layout/initedScreenListener']
    expect(result).toBe(true)
  })


})