feat(app && tests): refactor

This commit is contained in:
2024-03-28 10:31:29 +03:00
parent 49626cb681
commit 6e6e5311b0
96 changed files with 946 additions and 928 deletions

View File

@@ -1,6 +1,6 @@
import {test, describe, expect} from 'vitest'
import { mount} from '@vue/test-utils'
import Accordion from '@atoms/Accordion.vue';
import Accordion from '@atoms/VAccordion.vue';
describe('Accordion', () => {
test('Accordion mounted', () => {

View File

@@ -1,6 +1,6 @@
import {test, describe, expect} from 'vitest'
import { mount} from '@vue/test-utils'
import Button from '@atoms/Button.vue';
import Button from '@atoms/VButton.vue';
describe('Accordion', () => {
test('Accordion mounted', () => {

View File

@@ -4,7 +4,12 @@ import DoubleSwitch from '@atoms/DoubleSwitch.vue';
describe('DoubleSwitch', () => {
test('DoubleSwitch mounted', () => {
const wrapper = mount(DoubleSwitch)
const wrapper = mount(DoubleSwitch, {
global: {
provide: {
isChecked: false
}}
})
expect(wrapper.exists()).toBe(true)
})
})

View 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)
})
})

View 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 layoutMachines } from '@/store/modules/layoutMachines';
describe('VChart', () => {
test('VChart mounted', () => {
const store = createStore({
modules: {
layoutMachines
}
})
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)
})
})

View 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)
})
})

View 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)
})
})

View 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)
})
})

View 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)
})
})

View File

@@ -1,4 +1,5 @@
import Services from '@admin_pages/Services/index.vue'
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'
@@ -13,11 +14,11 @@ const store = createStore({
services: (state) => state.services,
},
mutations: {
setServices: (state, updval) => state.services = updval,
setServices: (state, updateValue) => state.services = updateValue,
},
})
describe("Services", () => {
describe("6_admin_pages, page of Services", () => {
it("renders Services, with custom button title", () => {
const wrapper = mount(Services, {
global: {
@@ -56,6 +57,7 @@ describe("Services", () => {
})
expect(store.state.services.length).toBeGreaterThan(0)
expect(wrapper.exists()).toBe(true)
})
})
@@ -70,5 +72,6 @@ describe("Services", () => {
store.commit('setServices', [])
expect(store.state.services.length).toBe(0)
expect(wrapper.exists()).toBe(true)
})
})

View File

@@ -1,40 +1,34 @@
import Service from '@admin_pages/Services/Service.vue'
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({
state() {
return {
services: globalServices,
}
},
getters: {
services: (state) => state.services,
},
mutations: {
setServices: (state, updval) => state.services = updval,
modules: {
logger,
services: globalServices,
},
})
describe("Service", () => {
it("renders Service, with set props value", async () => {
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)
})
})
describe("Service", () => {
it("renders Service with condition success", async () => {
test("renders Service with condition success", async () => {
const wrapper = mount(Service, {
global: {
plugins: [store],
@@ -48,10 +42,8 @@ describe("Service", () => {
expect(wrapper.html()).toContain('доступен')
})
})
describe("Service", () => {
it("renders Service with condition not success", async () => {
test("renders Service with condition not success", async () => {
const wrapper = mount(Service, {
global: {
plugins: [store],
@@ -65,10 +57,8 @@ describe("Service", () => {
expect(wrapper.html()).toContain('отключен')
})
})
describe("Service", () => {
it("renders Service if not service details", async () => {
test("renders Service if not service details", async () => {
const wrapper = mount(Service, {
global: {
plugins: [store],
@@ -80,10 +70,8 @@ describe("Service", () => {
expect(wrapper.html()).toContain('Сервис глобального хранилища применяется для условно постоянного хранения данных в кэше')
})
})
describe("Service", () => {
it("renders Service with set service details", async () => {
test("renders Service with set service details", async () => {
const wrapper = mount(Service, {
global: {
plugins: [store],
@@ -101,10 +89,8 @@ describe("Service", () => {
expect(wrapper.html()).toContain('доступен')
expect(wrapper.html()).toContain('... нет описания')
})
})
describe("Service", () => {
it("renders Service with alert copyText success after click", async () => {
test("renders Service with alert copyText success after click", async () => {
const wrapper = mount(Service, {
global: {
plugins: [store],
@@ -120,3 +106,4 @@ describe("Service", () => {
expect(wrapper.html()).toContain('copyed')
})
})