Initial commit
This commit is contained in:
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')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user