Initial commit
This commit is contained in:
39
tests/adapters/AdapterOfMachines.test.js
Normal file
39
tests/adapters/AdapterOfMachines.test.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import {describe, test, expect, vi} from 'vitest'
|
||||
import AdapterOfMachines from "@adapters/AdapterOfMachines.js"
|
||||
import axios from 'axios'
|
||||
import {apiModalListMachines, appModalListMachines, defaultLastMachines, resLastMachines} from "@mocks/machines.js"
|
||||
|
||||
vi.mock('axios')
|
||||
|
||||
|
||||
describe('AdapterOfMachines', () => {
|
||||
|
||||
test('AdapterOfMachines should be a object', () => {
|
||||
const adapterOfMachines = new AdapterOfMachines('')
|
||||
expect(typeof adapterOfMachines).toBe('object')
|
||||
})
|
||||
|
||||
test('test of fetchMachines', async () => {
|
||||
|
||||
axios.post.mockResolvedValue({data: apiModalListMachines})
|
||||
|
||||
const adapterOfMachines = new AdapterOfMachines('http://localhost:5444')
|
||||
const result = await adapterOfMachines.fetchModalMachines()
|
||||
expect(result).toEqual(appModalListMachines)
|
||||
})
|
||||
|
||||
test('Get last machines by pack number', async () => {
|
||||
|
||||
axios.post.mockResolvedValue({data: defaultLastMachines})
|
||||
const params = [7683]
|
||||
|
||||
const adapterOfPacks = new AdapterOfMachines('http://localhost:5444')
|
||||
const storeMachines = await adapterOfPacks.fetchLastMachinesByPackNum(params)
|
||||
|
||||
expect(storeMachines.length).toBeGreaterThan(0)
|
||||
expect(storeMachines.length).toBe(3)
|
||||
expect(storeMachines[0].packNumber).toBe(7683)
|
||||
expect(storeMachines[0]).toEqual(resLastMachines[0])
|
||||
})
|
||||
|
||||
})
|
||||
43
tests/adapters/ApiOfPacks.test.js
Normal file
43
tests/adapters/ApiOfPacks.test.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import {describe, test, expect, vi} from 'vitest'
|
||||
import ApiOfPacks from "@api/ApiOfPacks.js"
|
||||
import { defaultLastPacks, defaultFreePacks, defaultParams, freePacksParams } from '@mocks/packs'
|
||||
import axios from 'axios'
|
||||
|
||||
vi.mock('axios')
|
||||
|
||||
describe('ApiOfPacks', () => {
|
||||
|
||||
test('ApiOfPacks should be a object', () => {
|
||||
const apiOfPacks = new ApiOfPacks('')
|
||||
expect(typeof apiOfPacks).toBe('object')
|
||||
})
|
||||
|
||||
test('Get last packs', async () => {
|
||||
|
||||
axios.post.mockResolvedValue({data: defaultLastPacks})
|
||||
const params = [defaultParams.imei, defaultParams.dtStart, defaultParams.dtFinish]
|
||||
|
||||
const apiOfPacks = new ApiOfPacks('http://localhost:5444')
|
||||
const storePacks = await apiOfPacks.fetchLastPacks(params)
|
||||
|
||||
expect(storePacks.length).toBeGreaterThan(0)
|
||||
expect(storePacks.length).toBe(6)
|
||||
expect(storePacks[0].pack_number).toBe(1)
|
||||
expect(storePacks).toEqual(defaultLastPacks)
|
||||
})
|
||||
|
||||
test('Get free packs', async () => {
|
||||
|
||||
axios.post.mockResolvedValue({data: defaultFreePacks})
|
||||
const params = [freePacksParams[0]]
|
||||
|
||||
const apiOfPacks = new ApiOfPacks('http://localhost:5444')
|
||||
const storeFreePacks = await apiOfPacks.fetchFreePacks(params)
|
||||
|
||||
expect(storeFreePacks.logs.length).toBeGreaterThan(0)
|
||||
expect(storeFreePacks.logs.length).toBe(2)
|
||||
expect(storeFreePacks.maxDataLength).toEqual(defaultFreePacks.maxDataLength)
|
||||
expect(storeFreePacks).toEqual(defaultFreePacks)
|
||||
})
|
||||
|
||||
})
|
||||
10
tests/components/1_atoms/Accordion.test.js
Normal file
10
tests/components/1_atoms/Accordion.test.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import {test, describe, expect} from 'vitest'
|
||||
import { mount} from '@vue/test-utils'
|
||||
import Accordion from '@atoms/VAccordion.vue';
|
||||
|
||||
describe('Accordion', () => {
|
||||
test('Accordion mounted', () => {
|
||||
const wrapper = mount(Accordion)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
10
tests/components/1_atoms/Button.test.js
Normal file
10
tests/components/1_atoms/Button.test.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import {test, describe, expect} from 'vitest'
|
||||
import { mount} from '@vue/test-utils'
|
||||
import VButton from '@atoms/VButton.vue';
|
||||
|
||||
describe('VButton', () => {
|
||||
test('VButton mounted', () => {
|
||||
const wrapper = mount(VButton)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
10
tests/components/1_atoms/ButtonDiscard.test.js
Normal file
10
tests/components/1_atoms/ButtonDiscard.test.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import {test, describe, expect} from 'vitest'
|
||||
import { mount} from '@vue/test-utils'
|
||||
import ButtonDiscard from '@atoms/ButtonDiscard.vue';
|
||||
|
||||
describe('ButtonDiscard', () => {
|
||||
test('ButtonDiscard mounted', () => {
|
||||
const wrapper = mount(ButtonDiscard)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
10
tests/components/1_atoms/ButtonEdit.test.js
Normal file
10
tests/components/1_atoms/ButtonEdit.test.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import {test, describe, expect} from 'vitest'
|
||||
import { mount} from '@vue/test-utils'
|
||||
import ButtonEdit from '@atoms/ButtonEdit.vue';
|
||||
|
||||
describe('ButtonEdit', () => {
|
||||
test('ButtonEdit mounted', () => {
|
||||
const wrapper = mount(ButtonEdit)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
10
tests/components/1_atoms/ButtonSave.test.js
Normal file
10
tests/components/1_atoms/ButtonSave.test.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import {test, describe, expect} from 'vitest'
|
||||
import { mount} from '@vue/test-utils'
|
||||
import ButtonSave from '@atoms/ButtonSave.vue';
|
||||
|
||||
describe('ButtonSave', () => {
|
||||
test('ButtonSave mounted', () => {
|
||||
const wrapper = mount(ButtonSave)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
15
tests/components/1_atoms/DoubleSwitch.test.js
Normal file
15
tests/components/1_atoms/DoubleSwitch.test.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import {test, describe, expect} from 'vitest'
|
||||
import { mount} from '@vue/test-utils'
|
||||
import DoubleSwitch from '@atoms/DoubleSwitch.vue';
|
||||
|
||||
describe('DoubleSwitch', () => {
|
||||
test('DoubleSwitch mounted', () => {
|
||||
const wrapper = mount(DoubleSwitch, {
|
||||
global: {
|
||||
provide: {
|
||||
isChecked: false
|
||||
}}
|
||||
})
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
10
tests/components/2_molecules/ButtonModal.test.js
Normal file
10
tests/components/2_molecules/ButtonModal.test.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import {test, describe, expect, vi} from 'vitest'
|
||||
import { mount} from '@vue/test-utils'
|
||||
import ButtonModal from '@molecules/ButtonModal/ButtonModal.vue';
|
||||
|
||||
describe('ButtonModal', () => {
|
||||
test('ButtonModal mounted', () => {
|
||||
const wrapper = mount(ButtonModal)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
10
tests/components/2_molecules/MachinesModal.test.js
Normal file
10
tests/components/2_molecules/MachinesModal.test.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import {test, describe, expect, vi} from 'vitest'
|
||||
import { mount} from '@vue/test-utils'
|
||||
import MachinesModal from '@molecules/MachinesModal/MachinesModal.vue';
|
||||
|
||||
describe('MachinesModal', () => {
|
||||
test('MachinesModal mounted', () => {
|
||||
const wrapper = mount(MachinesModal)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
10
tests/components/2_molecules/MapModal.test.js
Normal file
10
tests/components/2_molecules/MapModal.test.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import {test, describe, expect} from 'vitest'
|
||||
import { mount} from '@vue/test-utils'
|
||||
import MapModal from '@molecules/MapModal/MapModal.vue';
|
||||
|
||||
describe('MapModal', () => {
|
||||
test('MapModal mounted', () => {
|
||||
const wrapper = mount(MapModal)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
46
tests/components/2_molecules/VChart.test.js
Normal file
46
tests/components/2_molecules/VChart.test.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import {test, describe, expect, vi} from 'vitest'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import VChart from '@molecules/VChart/VChart.vue';
|
||||
import { createStore } from 'vuex';
|
||||
import { store as layout_machines } from '@/store/modules/layout_machines';
|
||||
|
||||
describe('VChart', () => {
|
||||
test('VChart mounted', () => {
|
||||
|
||||
const store = createStore({
|
||||
modules: {
|
||||
layout_machines
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('@store/hooks/Echarts', () => {
|
||||
|
||||
const html = vi.fn(() => {
|
||||
return {
|
||||
getHtml: () => {
|
||||
return '<div>test</div>'
|
||||
},
|
||||
onClickedBarCharts: vi.fn()
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
__esModule: true,
|
||||
ECharts: html
|
||||
}
|
||||
})
|
||||
|
||||
const wrapper = shallowMount(VChart, {
|
||||
props: {
|
||||
id: "",
|
||||
type: "bar",
|
||||
},
|
||||
global: {
|
||||
mocks: {
|
||||
$store: store
|
||||
}
|
||||
}
|
||||
})
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
18
tests/components/2_molecules/VDatepicker.test.js
Normal file
18
tests/components/2_molecules/VDatepicker.test.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import {test, describe, expect, vi} from 'vitest'
|
||||
import { mount} from '@vue/test-utils'
|
||||
import VDatepicker from '@molecules/VDatepicker/VDatepicker.vue';
|
||||
|
||||
describe('VDatepicker', () => {
|
||||
test('VDatepicker mounted', () => {
|
||||
const wrapper = mount(VDatepicker,
|
||||
{
|
||||
global: {
|
||||
provide: {
|
||||
defaultDate: null
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
10
tests/components/2_molecules/VModal.test.js
Normal file
10
tests/components/2_molecules/VModal.test.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import {test, describe, expect} from 'vitest'
|
||||
import { mount} from '@vue/test-utils'
|
||||
import VModal from '@molecules/VModal/VModal.vue';
|
||||
|
||||
describe('VModal', () => {
|
||||
test('VModal mounted', () => {
|
||||
const wrapper = mount(VModal)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
10
tests/components/2_molecules/VSpinner.test.js
Normal file
10
tests/components/2_molecules/VSpinner.test.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import {test, describe, expect} from 'vitest'
|
||||
import { mount} from '@vue/test-utils'
|
||||
import VSpinner from '@molecules/VSpinner/VSpinner.vue';
|
||||
|
||||
describe('VSpinner', () => {
|
||||
test('VSpinner mounted', () => {
|
||||
const wrapper = mount(VSpinner)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
31
tests/components/2_molecules/VTabulator.test.js
Normal file
31
tests/components/2_molecules/VTabulator.test.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import {test, describe, expect, vi } from 'vitest'
|
||||
import { mount} from '@vue/test-utils'
|
||||
import VTabulator from '@molecules/VTabulator/VTabulator.vue';
|
||||
|
||||
describe("tests VTabulator component", () => {
|
||||
|
||||
vi.mock('tabulator-tables', () => {
|
||||
|
||||
const tabulator = vi.fn(() => {
|
||||
return {
|
||||
getHtml: () => {
|
||||
return '<div>test</div>'
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
__esModule: true,
|
||||
TabulatorFull: tabulator
|
||||
}
|
||||
})
|
||||
|
||||
test('exist test of VTabulator', async () => {
|
||||
|
||||
const wrapper = mount(VTabulator, {
|
||||
shallow: true,
|
||||
})
|
||||
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
27
tests/components/4_frames/AppContainer/AppContainer.test.js
Normal file
27
tests/components/4_frames/AppContainer/AppContainer.test.js
Normal file
@@ -0,0 +1,27 @@
|
||||
import {test, describe, expect, } from 'vitest'
|
||||
import { shallowMount} from '@vue/test-utils'
|
||||
import AppContainer from '@frames/AppContainer/AppContainer.vue';
|
||||
import {createStore} from "vuex";
|
||||
import { store as layout } from '@/store/modules/layout';
|
||||
import { store as auth } from '@/store/modules/auth';
|
||||
|
||||
describe('AppContainer', () => {
|
||||
const store = createStore({
|
||||
modules: {
|
||||
layout,
|
||||
auth
|
||||
},
|
||||
})
|
||||
|
||||
test('AppContainer mounted', () => {
|
||||
const wrapper = shallowMount(AppContainer,
|
||||
{
|
||||
global: {
|
||||
mocks: {
|
||||
$store: store,
|
||||
},
|
||||
}}
|
||||
)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
import {test, describe, expect, } from 'vitest'
|
||||
import { shallowMount} from '@vue/test-utils'
|
||||
import AppContainerBreadcrumbs from '@frames/AppContainer/AppContainerBreadcrumbs.vue';
|
||||
|
||||
describe('AppContainerBreadcrumbs', () => {
|
||||
test('AppContainerBreadcrumbs mounted', () => {
|
||||
const wrapper = shallowMount(AppContainerBreadcrumbs)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
import {test, describe, expect, } from 'vitest'
|
||||
import { shallowMount} from '@vue/test-utils'
|
||||
import AppContainerHeader from '@frames/AppContainer/AppContainerHeader.vue';
|
||||
|
||||
describe('AppContainerHeader', () => {
|
||||
test('AppContainerHeader mounted', () => {
|
||||
const wrapper = shallowMount(AppContainerHeader)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,16 @@
|
||||
import {test, describe, expect, } from 'vitest'
|
||||
import { shallowMount} from '@vue/test-utils'
|
||||
import AppContainerLeftPanel from '@frames/AppContainer/AppContainerLeftPanel.vue';
|
||||
import Router from "@router"
|
||||
|
||||
describe('AppContainerLeftPanel', () => {
|
||||
test('AppContainerLeftPanel mounted', () => {
|
||||
const wrapper = shallowMount(AppContainerLeftPanel,
|
||||
{
|
||||
global: {
|
||||
plugins: [Router]
|
||||
}
|
||||
})
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,15 @@
|
||||
import {test, describe, expect, } from 'vitest'
|
||||
import { shallowMount} from '@vue/test-utils'
|
||||
import AppContainerMobileMenu from '@frames/AppContainer/AppContainerMobileMenu.vue';
|
||||
|
||||
describe('AppContainerMobileMenu', () => {
|
||||
test('AppContainerMobileMenu mounted', () => {
|
||||
const wrapper = shallowMount(AppContainerMobileMenu, {
|
||||
props: {
|
||||
isOpenedMobileMenu: false,
|
||||
setIsMobileMenuOpened: () => {},
|
||||
}
|
||||
})
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,20 @@
|
||||
import {test, describe, expect, } from 'vitest'
|
||||
import { shallowMount} from '@vue/test-utils'
|
||||
import AppContainerRightPanel from '@frames/AppContainer/AppContainerRightPanel.vue';
|
||||
import Router from "@router"
|
||||
|
||||
describe('AppContainerRightPanel', () => {
|
||||
test('AppContainerRightPanel mounted', () => {
|
||||
const wrapper = shallowMount(AppContainerRightPanel, {
|
||||
props: {
|
||||
currentUser: {
|
||||
id: 1,
|
||||
}
|
||||
},
|
||||
global: {
|
||||
plugins: [Router]
|
||||
}
|
||||
})
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,15 @@
|
||||
import {test, describe, expect, } from 'vitest'
|
||||
import { shallowMount} from '@vue/test-utils'
|
||||
import MenuList from '@frames/AppContainer/MenuList/MenuList.vue';
|
||||
|
||||
describe('MenuList', () => {
|
||||
|
||||
test('MenuList mounted', () => {
|
||||
const wrapper = shallowMount(MenuList, {
|
||||
props: {
|
||||
routeName: ""
|
||||
}
|
||||
})
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,11 @@
|
||||
import {test, describe, expect, } from 'vitest'
|
||||
import { shallowMount} from '@vue/test-utils'
|
||||
import MenuListItem from '@frames/AppContainer/MenuList/MenuListItem.vue';
|
||||
|
||||
describe('MenuListItem', () => {
|
||||
|
||||
test('MenuListItem mounted', () => {
|
||||
const wrapper = shallowMount(MenuListItem)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
import {test, describe, expect, } from 'vitest'
|
||||
import { shallowMount} from '@vue/test-utils'
|
||||
import MenuListItemCopy from '@frames/AppContainer/MenuList/MenuListItemCopy.vue';
|
||||
|
||||
describe('MenuListItemCopy', () => {
|
||||
test('MenuListItemCopy mounted', () => {
|
||||
const wrapper = shallowMount(MenuListItemCopy)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
import {test, describe, expect, } from 'vitest'
|
||||
import { shallowMount} from '@vue/test-utils'
|
||||
import MenuListItemGroup from '@frames/AppContainer/MenuList/MenuListItemGroup.vue';
|
||||
|
||||
describe('MenuListItemGroup', () => {
|
||||
test('MenuListItemGroup mounted', () => {
|
||||
const wrapper = shallowMount(MenuListItemGroup)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,17 @@
|
||||
import {test, describe, expect, } from 'vitest'
|
||||
import { shallowMount} from '@vue/test-utils'
|
||||
import MenuListItemImplementation from '@frames/AppContainer/MenuList/MenuListItemImplementation.vue';
|
||||
import Router from "@router"
|
||||
|
||||
describe('MenuListItemImplementation', () => {
|
||||
|
||||
test('MenuListItemImplementation mounted', () => {
|
||||
const wrapper = shallowMount(MenuListItemImplementation,
|
||||
{
|
||||
global: {
|
||||
plugins: [Router]
|
||||
}
|
||||
})
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
import {test, describe, expect} from 'vitest'
|
||||
import { mount} from '@vue/test-utils'
|
||||
import PacksContainer from '@frames/PacksContainer/PacksContainer.vue';
|
||||
|
||||
describe('PacksContainer', () => {
|
||||
test('PacksContainer mounted', () => {
|
||||
const wrapper = mount(PacksContainer)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
import {test, describe, expect} from 'vitest'
|
||||
import { mount} from '@vue/test-utils'
|
||||
import PacksContainerBody from '@frames/PacksContainer/PacksContainerBody.vue';
|
||||
|
||||
describe('PacksContainerBody', () => {
|
||||
test('PacksContainerBody mounted', () => {
|
||||
const wrapper = mount(PacksContainerBody)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,10 @@
|
||||
import {test, describe, expect} from 'vitest'
|
||||
import { mount} from '@vue/test-utils'
|
||||
import PacksContainerControl from '@frames/PacksContainer//PacksContainerControl.vue';
|
||||
|
||||
describe('PacksContainerControl', () => {
|
||||
test('PacksContainerControl mounted', () => {
|
||||
const wrapper = mount(PacksContainerControl)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
77
tests/components/6_admin_pages/Services/Services.badtest.js
Normal file
77
tests/components/6_admin_pages/Services/Services.badtest.js
Normal file
@@ -0,0 +1,77 @@
|
||||
import {it, describe, expect} from 'vitest'
|
||||
import Services from '@admin_pages/Services/Services.vue'
|
||||
import { globalServices } from '@store/modules/services/StaticData'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import {createStore} from 'vuex'
|
||||
|
||||
const store = createStore({
|
||||
state() {
|
||||
return {
|
||||
services: globalServices,
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
services: (state) => state.services,
|
||||
},
|
||||
mutations: {
|
||||
setServices: (state, updateValue) => state.services = updateValue,
|
||||
},
|
||||
})
|
||||
|
||||
describe("6_admin_pages, page of Services", () => {
|
||||
it("renders Services, with custom button title", () => {
|
||||
const wrapper = mount(Services, {
|
||||
global: {
|
||||
plugins: [store],
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
titleServicesButton: 'Показать больше сервисов',
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
expect(wrapper.text()).toContain('Показать больше сервисов')
|
||||
})
|
||||
})
|
||||
|
||||
describe("Services", () => {
|
||||
it("renders after click button, open full Services", async () => {
|
||||
const wrapper = mount(Services, {
|
||||
global: {
|
||||
plugins: [store],
|
||||
},
|
||||
})
|
||||
|
||||
await wrapper.find('button').trigger('click')
|
||||
expect(wrapper.find('button').text()).toContain('Скрыть')
|
||||
})
|
||||
})
|
||||
|
||||
describe("Services", () => {
|
||||
it("renders Services with exists data", async () => {
|
||||
const wrapper = mount(Services, {
|
||||
global: {
|
||||
plugins: [store],
|
||||
},
|
||||
})
|
||||
|
||||
expect(store.state.services.length).toBeGreaterThan(0)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe("Services", () => {
|
||||
it("renders Services maked empty data", async () => {
|
||||
const wrapper = mount(Services, {
|
||||
global: {
|
||||
plugins: [store],
|
||||
},
|
||||
})
|
||||
|
||||
store.commit('setServices', [])
|
||||
|
||||
expect(store.state.services.length).toBe(0)
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,109 @@
|
||||
import {test, describe, expect} from 'vitest'
|
||||
import Service from '@admin_pages/Services/ServicesServiceItem.vue'
|
||||
import { globalServices } from '@store/modules/services/StaticData'
|
||||
import { store as logger } from '@/store/modules/logger';
|
||||
import { mount } from '@vue/test-utils'
|
||||
import {createStore} from 'vuex'
|
||||
|
||||
const store = createStore({
|
||||
modules: {
|
||||
logger,
|
||||
services: globalServices,
|
||||
},
|
||||
})
|
||||
|
||||
describe("6_admin_pages, ServicesServiceItem", () => {
|
||||
test("renders Service, with set props value", async () => {
|
||||
const wrapper = mount(Service, {
|
||||
global: {
|
||||
plugins: [store],
|
||||
},
|
||||
props: {
|
||||
idx: 1,
|
||||
}
|
||||
})
|
||||
|
||||
await wrapper.setProps({ idx: 3 })
|
||||
|
||||
expect(wrapper.html()).toContain(3)
|
||||
})
|
||||
|
||||
test("renders Service with condition success", async () => {
|
||||
const wrapper = mount(Service, {
|
||||
global: {
|
||||
plugins: [store],
|
||||
},
|
||||
props: {
|
||||
name: '',
|
||||
},
|
||||
})
|
||||
|
||||
await wrapper.setProps({ name: 'глобальное хранилище' })
|
||||
|
||||
expect(wrapper.html()).toContain('доступен')
|
||||
})
|
||||
|
||||
test("renders Service with condition not success", async () => {
|
||||
const wrapper = mount(Service, {
|
||||
global: {
|
||||
plugins: [store],
|
||||
},
|
||||
props: {
|
||||
name: '',
|
||||
},
|
||||
})
|
||||
|
||||
await wrapper.setProps({ name: 'Test service name' })
|
||||
|
||||
expect(wrapper.html()).toContain('отключен')
|
||||
})
|
||||
|
||||
test("renders Service if not service details", async () => {
|
||||
const wrapper = mount(Service, {
|
||||
global: {
|
||||
plugins: [store],
|
||||
},
|
||||
props: {
|
||||
service: {},
|
||||
},
|
||||
})
|
||||
|
||||
expect(wrapper.html()).toContain('Сервис глобального хранилища применяется для условно постоянного хранения данных в кэше')
|
||||
})
|
||||
|
||||
test("renders Service with set service details", async () => {
|
||||
const wrapper = mount(Service, {
|
||||
global: {
|
||||
plugins: [store],
|
||||
},
|
||||
props: {
|
||||
service: {serviceIp: '192.168.1.1', serviceCode: '1234567890', serviceLink: 'http://test.com', is_online: false,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
await wrapper.setProps({ service: {serviceIp: '192.168.1.7', serviceCode: '1234567897', is_online: true} }) // 1 раз, далее новый тест
|
||||
|
||||
expect(wrapper.html()).toContain('192.168.1.7')
|
||||
expect(wrapper.html()).toContain('1234567897')
|
||||
expect(wrapper.html()).toContain('доступен')
|
||||
expect(wrapper.html()).toContain('... нет описания')
|
||||
})
|
||||
|
||||
test("renders Service with alert copyText success after click", async () => {
|
||||
const wrapper = mount(Service, {
|
||||
global: {
|
||||
plugins: [store],
|
||||
},
|
||||
props: {
|
||||
copyed: '',
|
||||
service: {init_params: {service: 'Test service', machine_addr: 'Test machine_addr'}},
|
||||
},
|
||||
})
|
||||
|
||||
await wrapper.get('.copyText').trigger('click')
|
||||
|
||||
expect(wrapper.html()).toContain('copyed')
|
||||
})
|
||||
})
|
||||
|
||||
19
tests/helpers/apiHelpers.test.js
Normal file
19
tests/helpers/apiHelpers.test.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import axios from 'axios'
|
||||
import {describe, test, expect, vi} from 'vitest'
|
||||
import {apiModalListMachines} from "@mocks/machines.js"
|
||||
import {scandApiRequest} from "@helpers/apiHelpers.js"
|
||||
|
||||
vi.mock('axios')
|
||||
|
||||
describe('scandApiRequest', () => {
|
||||
test('scandApiRequest should be a function', () => {
|
||||
expect(typeof scandApiRequest).toBe('function')
|
||||
})
|
||||
|
||||
test('scandApiRequest should return a promise', async () => {
|
||||
axios.post.mockResolvedValue({data: apiModalListMachines})
|
||||
const result = await scandApiRequest('ScandApi.LiveMonitor.Machines', 'select_machines', [])
|
||||
expect(result).toEqual(apiModalListMachines)
|
||||
})
|
||||
})
|
||||
|
||||
143
tests/mocks/machines.js
Normal file
143
tests/mocks/machines.js
Normal file
@@ -0,0 +1,143 @@
|
||||
const apiModalMachine = {
|
||||
"zav_nomer": "007",
|
||||
"type": "АВФ-1М.2",
|
||||
"railway_name": "РЖД",
|
||||
"org_name": "ДКРЭ",
|
||||
"nomer_zn8": 19413152,
|
||||
"machine_type": "АВФ-1М.2 № 007",
|
||||
"machine_id": 5862,
|
||||
"imei": 868136032634217,
|
||||
"device_number": "КР190617",
|
||||
"device_id": 6248
|
||||
}
|
||||
|
||||
const appModalMachine = {
|
||||
"zavNomer": "007",
|
||||
"type": "АВФ-1М.2",
|
||||
"railwayName": "РЖД",
|
||||
"orgName": "ДКРЭ",
|
||||
"nomerZn8": 19413152,
|
||||
"machineType": "АВФ-1М.2 № 007",
|
||||
"machineId": 5862,
|
||||
"imei": 868136032634217,
|
||||
"deviceNumber": "КР190617",
|
||||
"deviceId": 6248
|
||||
}
|
||||
|
||||
const defaultLastMachines = [
|
||||
{
|
||||
"zav_nomer": "157",
|
||||
"type": "УК",
|
||||
"railway_name": "В-Сиб",
|
||||
"pack_number": 7683,
|
||||
"pack_dt": "2024-04-08T07:58:47.150000",
|
||||
"org_name": "ПМС-183",
|
||||
"nomer_zn8": 157,
|
||||
"machine_type": "УК-25/25",
|
||||
"machine_id": 3409,
|
||||
"imei": 868136034784234,
|
||||
"device_number": "КР214014",
|
||||
"device_id": 3302
|
||||
},
|
||||
{
|
||||
"zav_nomer": "162",
|
||||
"type": "УК",
|
||||
"railway_name": "Д-Вост",
|
||||
"pack_number": 7683,
|
||||
"pack_dt": "2024-04-08T04:10:03.250000",
|
||||
"org_name": "ПМС-233",
|
||||
"nomer_zn8": 162,
|
||||
"machine_type": "УК-25/25",
|
||||
"machine_id": 3425,
|
||||
"imei": 864004043339297,
|
||||
"device_number": "КР214015",
|
||||
"device_id": 3572
|
||||
},
|
||||
{
|
||||
"zav_nomer": "176",
|
||||
"type": "УК",
|
||||
"railway_name": "Заб",
|
||||
"pack_number": 7683,
|
||||
"pack_dt": "2024-04-05T05:39:04.392000",
|
||||
"org_name": "ПМС-185",
|
||||
"nomer_zn8": 176,
|
||||
"machine_type": "УК-25/25",
|
||||
"machine_id": 4619,
|
||||
"imei": 868136034805187,
|
||||
"device_number": "КР214038",
|
||||
"device_id": 3328
|
||||
}
|
||||
]
|
||||
|
||||
const resLastMachines = [
|
||||
{
|
||||
"zavNomer": "157",
|
||||
"type": "УК",
|
||||
"railwayName": "В-Сиб",
|
||||
"packNumber": 7683,
|
||||
"packDt": "2024-04-08T07:58:47.150000",
|
||||
"orgName": "ПМС-183",
|
||||
"nomerZn8": 157,
|
||||
"machineType": "УК-25/25",
|
||||
"machineId": 3409,
|
||||
"imei": 868136034784234,
|
||||
"deviceNumber": "КР214014",
|
||||
"deviceId": 3302
|
||||
},
|
||||
{
|
||||
"zavNomer": "162",
|
||||
"type": "УК",
|
||||
"railwayName": "Д-Вост",
|
||||
"packNumber": 7683,
|
||||
"packDt": "2024-04-08T04:10:03.250000",
|
||||
"orgName": "ПМС-233",
|
||||
"nomerZn8": 162,
|
||||
"machineType": "УК-25/25",
|
||||
"machineId": 3425,
|
||||
"imei": 864004043339297,
|
||||
"deviceNumber": "КР214015",
|
||||
"deviceId": 3572
|
||||
},
|
||||
{
|
||||
"zavNomer": "176",
|
||||
"type": "УК",
|
||||
"railwayName": "Заб",
|
||||
"packNumber": 7683,
|
||||
"packDt": "2024-04-05T05:39:04.392000",
|
||||
"orgName": "ПМС-185",
|
||||
"nomerZn8": 176,
|
||||
"machineType": "УК-25/25",
|
||||
"machineId": 4619,
|
||||
"imei": 868136034805187,
|
||||
"deviceNumber": "КР214038",
|
||||
"deviceId": 3328
|
||||
}
|
||||
]
|
||||
|
||||
const apiModalListMachines = [apiModalMachine]
|
||||
const appModalListMachines = [appModalMachine]
|
||||
|
||||
class AdapterOfMachines {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {Promise<Array>}
|
||||
*/
|
||||
async fetchModalMachines() {
|
||||
return appModalListMachines
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {Promise<Array>}
|
||||
*/
|
||||
async fetchLastMachinesByPackNum() {
|
||||
return resLastMachines
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { apiModalMachine, appModalMachine, apiModalListMachines, appModalListMachines, defaultLastMachines, resLastMachines, AdapterOfMachines }
|
||||
161
tests/mocks/packs.js
Normal file
161
tests/mocks/packs.js
Normal file
@@ -0,0 +1,161 @@
|
||||
const defaultParams = {
|
||||
"imei": "868136035512212",
|
||||
"dtStart": "2024-03-04T00:00:00",
|
||||
"dtFinish": "2024-04-04T23:59:00",
|
||||
}
|
||||
|
||||
const freePacksParams = [
|
||||
{
|
||||
"packs": [7683],
|
||||
"imei": "868136035512212",
|
||||
"dtStart": "2024-03-04T00:00:00",
|
||||
"dtFinish": "2024-04-04T23:59:00",
|
||||
},
|
||||
{
|
||||
"pagination": {"count": 2, "page": 2},
|
||||
"settings": {"date_param": "pack_dt", "sort_order": "asc"}
|
||||
}
|
||||
]
|
||||
|
||||
const defaultLastPacks = [{
|
||||
"pack_number": 1,
|
||||
"pack_dt": "2024-04-03T09:18:53.000000",
|
||||
"count": 6653
|
||||
},
|
||||
{
|
||||
"pack_number": 8,
|
||||
"pack_dt": "2024-04-03T09:05:42.477000",
|
||||
"count": 90
|
||||
},
|
||||
{
|
||||
"pack_number": 9,
|
||||
"pack_dt": "2024-04-03T09:05:42.477000",
|
||||
"count": 441
|
||||
},
|
||||
{
|
||||
"pack_number": 12,
|
||||
"pack_dt": "2024-04-03T06:30:56.601000",
|
||||
"count": 44963
|
||||
},
|
||||
{
|
||||
"pack_number": 13,
|
||||
"pack_dt": "2024-04-03T06:28:22.691000",
|
||||
"count": 1047
|
||||
},
|
||||
{
|
||||
"pack_number": 14,
|
||||
"pack_dt": "2024-04-03T06:30:57.208000",
|
||||
"count": 23281
|
||||
}]
|
||||
|
||||
const resPacks = [{
|
||||
"packNumber": 1,
|
||||
"packDt": "2024-04-03T09:18:53.000000",
|
||||
"count": 6653
|
||||
},
|
||||
{
|
||||
"packNumber": 8,
|
||||
"packDt": "2024-04-03T09:05:42.477000",
|
||||
"count": 90
|
||||
},
|
||||
{
|
||||
"packNumber": 9,
|
||||
"packDt": "2024-04-03T09:05:42.477000",
|
||||
"count": 441
|
||||
},
|
||||
{
|
||||
"packNumber": 12,
|
||||
"packDt": "2024-04-03T06:30:56.601000",
|
||||
"count": 44963
|
||||
},
|
||||
{
|
||||
"packNumber": 13,
|
||||
"packDt": "2024-04-03T06:28:22.691000",
|
||||
"count": 1047
|
||||
},
|
||||
{
|
||||
"packNumber": 14,
|
||||
"packDt": "2024-04-03T06:30:57.208000",
|
||||
"count": 23281
|
||||
}]
|
||||
|
||||
const defaultFreePacks = {
|
||||
"max_data_length": 69,
|
||||
"logs": [
|
||||
{
|
||||
"rcvd_dt": "2024-04-04T13:43:16.394540",
|
||||
"pack_number": 7683,
|
||||
"pack_dt": "2024-04-04T10:43:05.234000",
|
||||
"key": "20343046594D500B0028001A",
|
||||
"imei": 868136034800014,
|
||||
"id": 4236613068,
|
||||
"dt": "2024-04-04T13:43:18.878316",
|
||||
"data": "7683,384185234,57204033,39404035,4,2557,0,2,128,3,800281,788125,0",
|
||||
"arhiv_date": null
|
||||
},
|
||||
{
|
||||
"rcvd_dt": "2024-04-04T13:43:43.585266",
|
||||
"pack_number": 7683,
|
||||
"pack_dt": "2024-04-04T10:43:15.254000",
|
||||
"key": "20343046594D500B0028001A",
|
||||
"imei": 868136034800014,
|
||||
"id": 4236616912,
|
||||
"dt": "2024-04-04T13:43:47.427510",
|
||||
"data": "7683,384195254,57204036,39404033,0,2573,0,2,128,3,797447,806304,0",
|
||||
"arhiv_date": null
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
const resFreePacks = {
|
||||
"maxDataLength": 69,
|
||||
"logs": [
|
||||
{
|
||||
"rcvdDt": "2024-04-04T13:43:16.394540",
|
||||
"packNumber": 7683,
|
||||
"packDt": "2024-04-04T10:43:05.234000",
|
||||
"key": "20343046594D500B0028001A",
|
||||
"imei": 868136034800014,
|
||||
"id": 4236613068,
|
||||
"dt": "2024-04-04T13:43:18.878316",
|
||||
"data": "7683,384185234,57204033,39404035,4,2557,0,2,128,3,800281,788125,0",
|
||||
"arhivDate": null
|
||||
},
|
||||
{
|
||||
"rcvdDt": "2024-04-04T13:43:43.585266",
|
||||
"packNumber": 7683,
|
||||
"packDt": "2024-04-04T10:43:15.254000",
|
||||
"key": "20343046594D500B0028001A",
|
||||
"imei": 868136034800014,
|
||||
"id": 4236616912,
|
||||
"dt": "2024-04-04T13:43:47.427510",
|
||||
"data": "7683,384195254,57204036,39404033,0,2573,0,2,128,3,797447,806304,0",
|
||||
"arhivDate": null
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
class ApiOfPacks {
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {Promise<Array>}
|
||||
*/
|
||||
async fetchLastPacks() {
|
||||
return defaultLastPacks
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns {Promise<Array>}
|
||||
*/
|
||||
async fetchFreePacks() {
|
||||
return defaultFreePacks
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export {defaultLastPacks, resPacks, defaultFreePacks, resFreePacks, defaultParams, freePacksParams, ApiOfPacks}
|
||||
51
tests/services/ServiceOfLayout.test.js
Normal file
51
tests/services/ServiceOfLayout.test.js
Normal 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)
|
||||
})
|
||||
})
|
||||
46
tests/services/ServiceOfMachines.test.js
Normal file
46
tests/services/ServiceOfMachines.test.js
Normal 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])
|
||||
})
|
||||
|
||||
})
|
||||
46
tests/services/ServiceOfPacks.test.js
Normal file
46
tests/services/ServiceOfPacks.test.js
Normal 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)
|
||||
})
|
||||
|
||||
})
|
||||
32
tests/store/freePacks.test.js
Normal file
32
tests/store/freePacks.test.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import {describe, test, expect, beforeEach} from 'vitest'
|
||||
import {createStore} from "vuex"
|
||||
import { store as packs } from '@/store/modules/packs'
|
||||
|
||||
describe('Test free packs store', () => {
|
||||
const store = createStore({
|
||||
modules: {
|
||||
packs
|
||||
}
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
store.dispatch('packs/resetStore')
|
||||
})
|
||||
|
||||
test('Packs should be a object', () => {
|
||||
expect(typeof packs).toBe('object')
|
||||
})
|
||||
|
||||
test('Free packs should be a object, set and get from store', async () => {
|
||||
|
||||
const defaultPacksStore = store.getters['packs/freePacks']
|
||||
|
||||
expect(defaultPacksStore).toEqual({})
|
||||
|
||||
store.dispatch('packs/setFreePacks', {"maxDataLength": 70, logs:[1, 2, 3]})
|
||||
|
||||
const freePacksStore = store.getters['packs/freePacks']
|
||||
|
||||
expect(freePacksStore).toEqual({"maxDataLength": 70, logs:[1, 2, 3]})
|
||||
})
|
||||
})
|
||||
33
tests/store/lastMachinesByPackNum.test.js
Normal file
33
tests/store/lastMachinesByPackNum.test.js
Normal file
@@ -0,0 +1,33 @@
|
||||
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])
|
||||
})
|
||||
})
|
||||
32
tests/store/lastPacks.test.js
Normal file
32
tests/store/lastPacks.test.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import {describe, test, expect, beforeEach} from 'vitest'
|
||||
import {createStore} from "vuex"
|
||||
import { store as packs } from '@/store/modules/packs';
|
||||
describe('Test last packs store', () => {
|
||||
const store = createStore({
|
||||
modules: {
|
||||
packs
|
||||
}
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
store.dispatch('packs/resetStore')
|
||||
})
|
||||
|
||||
test('Packs should be a object', () => {
|
||||
expect(typeof packs).toBe('object')
|
||||
})
|
||||
|
||||
test('Last packs should be a array, set and get from store', () => {
|
||||
|
||||
const defaultPacksStore = store.getters['packs/lastPacks']
|
||||
|
||||
expect(defaultPacksStore.length).toBe(0)
|
||||
expect(defaultPacksStore).toEqual([])
|
||||
|
||||
store.dispatch('packs/setLastPacks', [1, 2, 3])
|
||||
|
||||
const newPacksStore = store.getters['packs/lastPacks']
|
||||
|
||||
expect(newPacksStore).toEqual([1, 2, 3])
|
||||
})
|
||||
})
|
||||
53
tests/store/layout.test.js
Normal file
53
tests/store/layout.test.js
Normal file
@@ -0,0 +1,53 @@
|
||||
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)
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
24
tests/store/machines.test.js
Normal file
24
tests/store/machines.test.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import {describe, test, expect, beforeEach} from 'vitest'
|
||||
import {createStore} from "vuex"
|
||||
import { store as machines } from '@/store/modules/machines';
|
||||
describe('machines store', () => {
|
||||
const store = createStore({
|
||||
modules: {
|
||||
machines
|
||||
}
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
store.dispatch('machines/resetStore')
|
||||
})
|
||||
|
||||
test('machines should be a object', () => {
|
||||
expect(typeof machines).toBe('object')
|
||||
})
|
||||
|
||||
test('modalMachines should be a array', () => {
|
||||
expect(store.getters['machines/modalMachines']).toEqual([])
|
||||
store.dispatch('machines/setModalMachines', [1, 2, 3])
|
||||
expect(store.getters['machines/modalMachines']).toEqual([1, 2, 3])
|
||||
})
|
||||
})
|
||||
16
tests/views/1_atoms/VButton.test.js
Normal file
16
tests/views/1_atoms/VButton.test.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import {test, describe, expect} from 'vitest'
|
||||
import {mount} from '@vue/test-utils'
|
||||
import VButton from '@atoms/VButton.vue';
|
||||
|
||||
describe("tests VButton component", () => {
|
||||
test('mount test of VButton', async () => {
|
||||
|
||||
const wrapper = mount(VButton, {
|
||||
shallow: true,
|
||||
})
|
||||
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
16
tests/views/1_atoms/VInput.test.js
Normal file
16
tests/views/1_atoms/VInput.test.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import {test, describe, expect} from 'vitest'
|
||||
import {mount} from '@vue/test-utils'
|
||||
import VInput from '@atoms/VInput.vue';
|
||||
|
||||
describe("tests VInput component", () => {
|
||||
test('exist test of VInput', async () => {
|
||||
|
||||
const wrapper = mount(VInput, {
|
||||
shallow: true,
|
||||
})
|
||||
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
138
tests/views/3_organisms/FreePacks.test.js
Normal file
138
tests/views/3_organisms/FreePacks.test.js
Normal file
@@ -0,0 +1,138 @@
|
||||
import {expect, describe, test, beforeEach, vi} from 'vitest'
|
||||
import {mount} from '@vue/test-utils'
|
||||
import ServiceOfPacks from "@services/ServiceOfPacks.js"
|
||||
import {ApiOfPacks, freePacksParams, resFreePacks} from "@mocks/packs.js"
|
||||
import FreePacks from "@organisms/FreePacks/FreePacks.vue"
|
||||
import tableConfig from '@organisms/FreePacks/helpers/tableConfig'
|
||||
import { createStore } from "vuex"
|
||||
import { store as packs } from '@/store/modules/packs'
|
||||
|
||||
describe('test FreePacks', () => {
|
||||
|
||||
const apiOfPacks = new ApiOfPacks()
|
||||
const store = createStore({
|
||||
modules: {
|
||||
packs
|
||||
}
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
store.dispatch('packs/resetStore')
|
||||
})
|
||||
|
||||
vi.mock('tabulator-tables', () => {
|
||||
const mockTabulator = vi.fn().mockImplementation(() => ({
|
||||
// Mock implementation details
|
||||
}))
|
||||
return { TabulatorFull: mockTabulator } // Adjust based on what you're trying to mock
|
||||
})
|
||||
|
||||
const serviceOfPacks = new ServiceOfPacks(apiOfPacks, store)
|
||||
|
||||
test('exist of FreePacks', async () => {
|
||||
|
||||
const wrapper = mount(FreePacks, {
|
||||
global: {
|
||||
mocks: {
|
||||
$store: store
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
|
||||
test('Edit fields in FreePacks component', async () => {
|
||||
|
||||
const wrapper = mount(FreePacks, {
|
||||
shallow: true,
|
||||
global: {
|
||||
mocks: {
|
||||
$store: store
|
||||
},
|
||||
props: {
|
||||
serviceOfPacks,
|
||||
},
|
||||
data() {
|
||||
const paramsFields = {
|
||||
dateFormat: "DD.MM.YYYY",
|
||||
dtStart: '',
|
||||
dtFinish: new Date(),
|
||||
imei: '',
|
||||
packNumber: '',
|
||||
sortBy: 'pack_dt',
|
||||
countEntries: '10',
|
||||
sortByOptions: ['pack_dt', 'dt'],
|
||||
countEntriesOptions: ['10', '500', '2000', '10000', '50000', '100000']
|
||||
}
|
||||
return {
|
||||
config: tableConfig,
|
||||
paramsFields,
|
||||
pageState: "await", // await | loading | isLoaded | error
|
||||
errorImei: null,
|
||||
errorPackNumber: null,
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
await serviceOfPacks.setPackFields(wrapper.vm.paramsFields, {key: 'imei', value: '868136035512212'})
|
||||
await serviceOfPacks.setPackFields(wrapper.vm.paramsFields, {key: 'dtStart', value: '2024-03-05'})
|
||||
await serviceOfPacks.setPackFields(wrapper.vm.paramsFields, {key: 'dtFinish', value: '2024-04-05'})
|
||||
await serviceOfPacks.setPackFields(wrapper.vm.paramsFields, {key: 'packNumber', value: '333444555'})
|
||||
await serviceOfPacks.setPackFields(wrapper.vm.paramsFields, {key: 'sortBy', value: 'dt'})
|
||||
await serviceOfPacks.setPackFields(wrapper.vm.paramsFields, {key: 'countEntries', value: '500'})
|
||||
|
||||
expect(wrapper.vm.paramsFields).toEqual({
|
||||
dateFormat: "DD.MM.YYYY",
|
||||
imei: '868136035512212',
|
||||
dtStart: '2024-03-05',
|
||||
dtFinish: '2024-04-05',
|
||||
packNumber: '333444555',
|
||||
sortBy: 'dt',
|
||||
countEntries: '500',
|
||||
sortByOptions: ['pack_dt', 'dt'],
|
||||
countEntriesOptions: ['10', '500', '2000', '10000', '50000', '100000']
|
||||
})
|
||||
})
|
||||
|
||||
test('Get free packs in FreePacks component', async () => {
|
||||
|
||||
const wrapper = mount(FreePacks, {
|
||||
shallow: true,
|
||||
global: {
|
||||
mocks: {
|
||||
$store: store
|
||||
},
|
||||
props: {
|
||||
serviceOfPacks,
|
||||
},
|
||||
data() {
|
||||
const paramsFields = {
|
||||
dtStart: '',
|
||||
dtFinish: '',
|
||||
imei: ''
|
||||
}
|
||||
return {
|
||||
config: tableConfig,
|
||||
paramsFields,
|
||||
pageState: "await", // await | loading | isLoaded | error
|
||||
errorImei: null,
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
await wrapper.setData({paramsFields: {imei: '868136035512212'}})
|
||||
|
||||
await serviceOfPacks.fetchAndSetFreePacks(freePacksParams)
|
||||
|
||||
const freePacks = store.getters['packs/freePacks']
|
||||
|
||||
expect(freePacks).toEqual(resFreePacks)
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
107
tests/views/3_organisms/LastMachinesByPackNum.test.js
Normal file
107
tests/views/3_organisms/LastMachinesByPackNum.test.js
Normal file
@@ -0,0 +1,107 @@
|
||||
import {expect, describe, test, vi} from 'vitest'
|
||||
import {mount} from '@vue/test-utils'
|
||||
import LastMachinesByPackNum from '@organisms/LastMachinesByPackNumber/LastMachinesByPackNum.vue'
|
||||
import tableConfig from '@organisms/LastMachinesByPackNumber/helpers/tableConfig'
|
||||
import { createStore } from "vuex"
|
||||
import { store as machines } from '@/store/modules/machines'
|
||||
import ServiceOfMachines from "@services/ServiceOfMachines"
|
||||
import {resLastMachines, AdapterOfMachines} from "@mocks/machines.js"
|
||||
|
||||
describe('test LastPacksByPackNum component', () => {
|
||||
|
||||
const adapterOfMachines = new AdapterOfMachines()
|
||||
const store = createStore({
|
||||
modules: {
|
||||
machines
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('tabulator-tables', () => {
|
||||
const mockTabulator = vi.fn().mockImplementation(() => ({
|
||||
// Mock implementation details
|
||||
}))
|
||||
return { TabulatorFull: mockTabulator } // Adjust based on what you're trying to mock
|
||||
})
|
||||
|
||||
const serviceOfMachines = new ServiceOfMachines(adapterOfMachines, store)
|
||||
|
||||
test('exist test of LastMachinesByPackNum', async () => {
|
||||
|
||||
const wrapper = mount(LastMachinesByPackNum, {
|
||||
global: {
|
||||
mocks: {
|
||||
$store: store
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
|
||||
test('Get last machines by packs numbers in LastMachinesByPackNum component', async () => {
|
||||
|
||||
const wrapper = mount(LastMachinesByPackNum, {
|
||||
shallow: true,
|
||||
global: {
|
||||
mocks: {
|
||||
$store: store
|
||||
},
|
||||
props: {
|
||||
serviceOfMachines,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
packs: '',
|
||||
config: tableConfig,
|
||||
pageState: "await", // await | loading | isLoaded | error
|
||||
errorPacks: null,
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
await wrapper.setData({packs: [[7683, 7684, 7685]]})
|
||||
|
||||
const packsFromData = wrapper.vm.packs
|
||||
|
||||
await serviceOfMachines.fetchAndSetLastMachinesByPackNum(packsFromData)
|
||||
|
||||
const lastMachines = store.getters['machines/lastMachinesByPackNumber']
|
||||
|
||||
expect(lastMachines).toEqual(resLastMachines)
|
||||
|
||||
})
|
||||
|
||||
test('Edit field packs in LastMachinesByPackNum component', async () => {
|
||||
|
||||
const wrapper = mount(LastMachinesByPackNum, {
|
||||
shallow: true,
|
||||
global: {
|
||||
mocks: {
|
||||
$store: store
|
||||
},
|
||||
props: {
|
||||
serviceOfMachines,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
packs: '',
|
||||
config: tableConfig,
|
||||
pageState: "await", // await | loading | isLoaded | error
|
||||
errorPacks: null,
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
await wrapper.vm.editPacks('7681, 7682, 7683')
|
||||
|
||||
const packsFromData = wrapper.vm.packs
|
||||
|
||||
expect(packsFromData).toEqual('7681, 7682, 7683')
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
138
tests/views/3_organisms/LastPacks.test.js
Normal file
138
tests/views/3_organisms/LastPacks.test.js
Normal file
@@ -0,0 +1,138 @@
|
||||
import {expect, describe, test, beforeEach, vi} from 'vitest'
|
||||
import {mount} from '@vue/test-utils'
|
||||
import ServiceOfPacks from "@services/ServiceOfPacks.js"
|
||||
import {resPacks, ApiOfPacks} from "@mocks/packs.js"
|
||||
import LastPacks from "@organisms/LastPacks/LastPacks.vue"
|
||||
import tableConfig from '@organisms/LastPacks/helpers/tableConfig'
|
||||
import { createStore } from "vuex"
|
||||
import { store as packs } from '@/store/modules/packs'
|
||||
|
||||
describe('test LastPacks', () => {
|
||||
|
||||
const apiOfPacks = new ApiOfPacks()
|
||||
const store = createStore({
|
||||
modules: {
|
||||
packs
|
||||
}
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
store.dispatch('packs/resetStore')
|
||||
})
|
||||
|
||||
vi.mock('tabulator-tables', () => {
|
||||
const mockTabulator = vi.fn().mockImplementation(() => ({
|
||||
// Mock implementation details
|
||||
}))
|
||||
return { TabulatorFull: mockTabulator } // Adjust based on what you're trying to mock
|
||||
})
|
||||
|
||||
const serviceOfPacks = new ServiceOfPacks(apiOfPacks, store)
|
||||
|
||||
test('exist of LastPacks', async () => {
|
||||
|
||||
const wrapper = mount(LastPacks, {
|
||||
props: {
|
||||
serviceOfPacks,
|
||||
},
|
||||
global: {
|
||||
mocks: {
|
||||
$store: store
|
||||
},
|
||||
data() {
|
||||
const paramsFields = {
|
||||
dateFormat: 'DD.MM.YYYY HH:mm',
|
||||
dtStart: serviceOfPacks.getDefaultDates(this.dateFormat).dtStart,
|
||||
dtFinish: serviceOfPacks.getDefaultDates(this.dateFormat).dtFinish,
|
||||
imei: ''
|
||||
}
|
||||
return {
|
||||
config: tableConfig,
|
||||
paramsFields,
|
||||
pageState: "await", // await | loading | isLoaded | error
|
||||
errorImei: null,
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
|
||||
test('Get last packs in LastPacks component', async () => {
|
||||
|
||||
const wrapper = mount(LastPacks, {
|
||||
shallow: true,
|
||||
props: {
|
||||
serviceOfPacks,
|
||||
},
|
||||
global: {
|
||||
mocks: {
|
||||
$store: store
|
||||
},
|
||||
data() {
|
||||
const paramsFields = {
|
||||
dateFormat: 'DD.MM.YYYY HH:mm',
|
||||
dtStart: serviceOfPacks.getDefaultDates(this.dateFormat).dtStart,
|
||||
dtFinish: serviceOfPacks.getDefaultDates(this.dateFormat).dtFinish,
|
||||
imei: ''
|
||||
}
|
||||
return {
|
||||
config: tableConfig,
|
||||
paramsFields,
|
||||
pageState: "await", // await | loading | isLoaded | error
|
||||
errorImei: null,
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
await wrapper.setData({paramsFields: {imei: '868136035512212'}})
|
||||
|
||||
await wrapper.vm.getPacks()
|
||||
|
||||
const lastPacks = store.getters['packs/lastPacks']
|
||||
|
||||
expect(lastPacks).toEqual(resPacks)
|
||||
|
||||
})
|
||||
|
||||
test('Edit fields in LastPacks component', async () => {
|
||||
|
||||
const wrapper = mount(LastPacks, {
|
||||
shallow: true,
|
||||
props: {
|
||||
serviceOfPacks,
|
||||
},
|
||||
global: {
|
||||
mocks: {
|
||||
$store: store
|
||||
},
|
||||
data() {
|
||||
const paramsFields = {
|
||||
dateFormat: 'DD.MM.YYYY HH:mm',
|
||||
dtStart: serviceOfPacks.getDefaultDates(this.dateFormat).dtStart,
|
||||
dtFinish: serviceOfPacks.getDefaultDates(this.dateFormat).dtFinish,
|
||||
imei: ''
|
||||
}
|
||||
return {
|
||||
config: tableConfig,
|
||||
paramsFields,
|
||||
pageState: "await", // await | loading | isLoaded | error
|
||||
errorImei: null,
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
await wrapper.vm.editFields({key: 'imei', value: '868136035512212'})
|
||||
await wrapper.vm.editFields({key: 'dtStart', value: '2024-03-05'})
|
||||
await wrapper.vm.editFields({key: 'dtFinish', value: '2024-04-05'})
|
||||
|
||||
expect(wrapper.vm.paramsFields).toEqual({dateFormat: 'DD.MM.YYYY HH:mm', imei: '868136035512212', dtStart: '2024-03-05', dtFinish: '2024-04-05'})
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
39
tests/views/5_pages/FreePacksPage.test.js
Normal file
39
tests/views/5_pages/FreePacksPage.test.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import {expect, describe, test, beforeEach} from 'vitest'
|
||||
import {mount} from '@vue/test-utils'
|
||||
import ServiceOfPacks from "@services/ServiceOfPacks.js"
|
||||
import {ApiOfPacks} from "@mocks/packs.js"
|
||||
import FreePacksPage from "@pages/FreePacks/index.vue"
|
||||
import { createStore } from "vuex"
|
||||
import { store as packs } from '@/store/modules/packs'
|
||||
|
||||
describe('test FreePacksPage', () => {
|
||||
|
||||
const apiOfPacks = new ApiOfPacks()
|
||||
const store = createStore({
|
||||
modules: {
|
||||
packs
|
||||
}
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
store.dispatch('packs/resetStore')
|
||||
})
|
||||
|
||||
const serviceOfPacks = new ServiceOfPacks(apiOfPacks, store)
|
||||
|
||||
test('exist test of FreePacksPage', async () => {
|
||||
|
||||
const wrapper = mount(FreePacksPage, {
|
||||
shallow: true,
|
||||
})
|
||||
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
|
||||
test('Service serviceOfPacks should be a object', () => {
|
||||
expect(typeof serviceOfPacks).toBe('object')
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
35
tests/views/5_pages/LastMachinesByPackNumPage.test.js
Normal file
35
tests/views/5_pages/LastMachinesByPackNumPage.test.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import {expect, describe, test} from 'vitest'
|
||||
import {mount} from '@vue/test-utils'
|
||||
import LastMachinesPackNum from "@pages/LastMachinesPackNum/index.vue"
|
||||
import { createStore } from "vuex"
|
||||
import { store as machines } from '@/store/modules/machines'
|
||||
import ServiceOfMachines from "@services/ServiceOfMachines"
|
||||
import {AdapterOfMachines} from "@mocks/machines.js"
|
||||
|
||||
describe('test LastMachinesPackNum page', () => {
|
||||
|
||||
const adapterOfMachines = new AdapterOfMachines()
|
||||
const store = createStore({
|
||||
modules: {
|
||||
machines
|
||||
}
|
||||
})
|
||||
|
||||
const serviceOfMachines = new ServiceOfMachines(adapterOfMachines, store)
|
||||
|
||||
test('exist test of LastMachinesPackNum', async () => {
|
||||
|
||||
const wrapper = mount(LastMachinesPackNum, {
|
||||
shallow: true,
|
||||
})
|
||||
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
|
||||
test('Service serviceOfMachines should be a object', () => {
|
||||
expect(typeof serviceOfMachines).toBe('object')
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
39
tests/views/5_pages/LastPacksPage.test.js
Normal file
39
tests/views/5_pages/LastPacksPage.test.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import {expect, describe, test, beforeEach} from 'vitest'
|
||||
import {mount} from '@vue/test-utils'
|
||||
import ServiceOfPacks from "@services/ServiceOfPacks.js"
|
||||
import {ApiOfPacks} from "@mocks/packs.js"
|
||||
import LastPacksPage from "@pages/LastPacks/index.vue"
|
||||
import { createStore } from "vuex"
|
||||
import { store as packs } from '@/store/modules/packs'
|
||||
|
||||
describe('test LastPacksPage', () => {
|
||||
|
||||
const apiOfPacks = new ApiOfPacks()
|
||||
const store = createStore({
|
||||
modules: {
|
||||
packs
|
||||
}
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
store.dispatch('packs/resetStore')
|
||||
})
|
||||
|
||||
const serviceOfPacks = new ServiceOfPacks(apiOfPacks, store)
|
||||
|
||||
test('exist test of LastPacksPage', async () => {
|
||||
|
||||
const wrapper = mount(LastPacksPage, {
|
||||
shallow: true,
|
||||
})
|
||||
|
||||
expect(wrapper.exists()).toBe(true)
|
||||
})
|
||||
|
||||
test('Service serviceOfPacks should be a object', () => {
|
||||
expect(typeof serviceOfPacks).toBe('object')
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user