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

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

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

  const serviceOfLayout = new ServiceOfLayout(store)

  test('test ServiceOfLayout exist', async () => {
    expect(serviceOfLayout).toBeTruthy()
    expect(serviceOfLayout.getHeight()).toBe(0)
    expect(serviceOfLayout.getWidth()).toBe(0)
    expect(serviceOfLayout.getIsOpenMenu()).toBe(false)
    expect(serviceOfLayout.getIsEnabledMenu()).toBe(true)
    expect(serviceOfLayout.getIsShowMenu()).toBe(true)
  })

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

  test('setIsShowMenu', async () => {
    serviceOfLayout.setIsShowMenu(false)
    const result = serviceOfLayout.getIsShowMenu()
    expect(result).toBe(false)
  })

  test('setIsOpenMenu', async () => {
    serviceOfLayout.setIsOpenMenu(true)
    const result = serviceOfLayout.getIsOpenMenu()
    expect(result).toBe(true)
  })

  test('setIsEnabledMenu', async () => {
    serviceOfLayout.setIsEnabledMenu(false)
    const result = serviceOfLayout.getIsEnabledMenu()
    expect(result).toBe(false)
  })
})