Initial commit

This commit is contained in:
2024-04-24 11:13:56 +03:00
commit 22d37bb0a4
301 changed files with 86455 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
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)
})
})

View File

@@ -0,0 +1,46 @@
import {expect, describe, test, beforeEach} from 'vitest'
import ServiceOfMachines from "@services/ServiceOfMachines.js"
import {appModalListMachines, resLastMachines, AdapterOfMachines} from "@mocks/machines.js"
import { createStore } from "vuex"
import { store as machines } from '@/store/modules/machines'
describe('test ServiceOfMachines', () => {
const adapterOfMachines = new AdapterOfMachines()
const store = createStore({
modules: {
machines
}
})
beforeEach(() => {
store.dispatch('machines/resetStore')
})
const serviceOfMachines = new ServiceOfMachines(adapterOfMachines, store)
test('Get machines for modal with func getModalMachines', async () => {
const result = await serviceOfMachines.fetchModalMachines()
expect(result).toEqual(appModalListMachines)
})
test('Get machines for modal in store with func getAndPutModalMachines', async () => {
const funcResult = await serviceOfMachines.fetchAndSetModalMachines()
const storeResult = store.getters['machines/modalMachines']
expect(funcResult).toEqual(appModalListMachines)
expect(storeResult).toEqual(appModalListMachines)
})
test('Get last machines by pack number with func getLastMachinesByPackNum', async () => {
const result = await serviceOfMachines.fetchLastMachinesByPackNum([7683])
expect(result[0]).toEqual(resLastMachines[0])
})
test('Get last machines in store with func getAndPutLastMachinesByPackNum', async () => {
const funcResult = await serviceOfMachines.fetchAndSetLastMachinesByPackNum([7683])
const storeResult = store.getters['machines/lastMachinesByPackNumber']
expect(funcResult[0]).toEqual(resLastMachines[0])
expect(storeResult[0]).toEqual(resLastMachines[0])
})
})

View File

@@ -0,0 +1,46 @@
import {expect, describe, test, beforeEach} from 'vitest'
import ServiceOfPacks from "@services/ServiceOfPacks.js"
import {resPacks, resFreePacks, defaultParams, freePacksParams, ApiOfPacks} from "@mocks/packs.js"
import { createStore } from "vuex"
import { store as packs } from '@/store/modules/packs'
describe('test ServiceOfPacks', () => {
const apiOfPacks = new ApiOfPacks()
const store = createStore({
modules: {
packs
}
})
beforeEach(() => {
store.dispatch('packs/resetStore')
})
const serviceOfPacks = new ServiceOfPacks(apiOfPacks, store)
test('Get last packs with func fetchLastPacks', async () => {
const result = await serviceOfPacks.fetchLastPacks(defaultParams.imei, defaultParams.dtStart, defaultParams.dtFinish)
expect(result).toEqual(resPacks)
})
test('Get last packs in store with func fetchAndSetLastPacks', async () => {
const funcResult = await serviceOfPacks.fetchAndSetLastPacks(defaultParams.imei, defaultParams.dtStart, defaultParams.dtFinish)
const storeResult = store.getters['packs/lastPacks']
expect(funcResult).toEqual(resPacks)
expect(storeResult).toEqual(resPacks)
})
test('Get free packs with func fetchFreePacks', async () => {
const result = await serviceOfPacks.fetchFreePacks(freePacksParams)
expect(result).toEqual(resFreePacks)
})
test('Get free packs in store with func fetchAndSetFreePacks', async () => {
const funcResult = await serviceOfPacks.fetchAndSetFreePacks(freePacksParams)
const storeResult = store.getters['packs/freePacks']
expect(funcResult).toEqual(resFreePacks)
expect(storeResult).toEqual(resFreePacks)
})
})