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

describe('Test last machines by pack number store', () => {
  const store = createStore({
    modules: {
      machines
    }
  })

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

  test('Last machines should be a object', () => {
    expect(typeof machines).toBe('object')
  })

  test('Last machines should be a array', () => {

    const defaultMachinesStore = store.getters['machines/lastMachinesByPackNumber']

    expect(defaultMachinesStore.length).toBe(0)
    expect(defaultMachinesStore).toEqual([])

    store.dispatch('machines/setLastMachinesByPackNumber', [1, 2, 3])

    const updatedMachinesStore = store.getters['machines/lastMachinesByPackNumber']
    
    expect(updatedMachinesStore).toEqual([1, 2, 3])
  })
})