updated Service of Users, updated tests

This commit is contained in:
2024-04-03 11:58:49 +03:00
parent 2b2ad786b2
commit 327f716fe9
17 changed files with 314 additions and 644 deletions

View File

@@ -6,6 +6,7 @@ import axios from "axios";
import {store as services} from "@/store/modules/services"
import AdapterOfServices from '@adapters/adapterOfServices/Services'
import ServiceOfServices from '@services/serviceOfServices/Services.js'
import {defaultServices, resServices} from "@mocks/services"
config.showDeprecationWarnings = false
@@ -20,39 +21,6 @@ describe("tests EditServiceCard component", () => {
},
})
const defaultServices = [
{
"id": 1,
"created_at": "2024-03-06T17:31:31.948355541+03:00",
"updated_at": "2024-03-06T17:31:31.948355541+03:00",
"deleted_at": null,
"name": "jsonplaceholder.typicode.com",
"port": 9965,
"proxy_ip": "172.25.78.153",
"site_ip": "https://jsonplaceholder.typicode.com/",
"internet_uri": "localhost",
"description": "localhost",
"is_online": true
},
]
const resServices = [
{
"id": 1,
"created_at": "2024-03-06T17:31:31.948355541+03:00",
"updated_at": "2024-03-06T17:31:31.948355541+03:00",
"deleted_at": null,
"name": "jsonplaceholder.typicode.com",
"port": 9965,
"proxy_ip": "172.25.78.153",
"device_ip": "https://jsonplaceholder.typicode.com/",
"internet_uri": "localhost",
"description": "localhost",
"is_online": true
},
]
axios.get.mockResolvedValue({
data: defaultServices,
})
@@ -71,7 +39,9 @@ describe("tests EditServiceCard component", () => {
const wrapper = mount(EditServiceCard, {
global: {
plugins: [store]
mocks: {
$store: store
}
},
props: {
serviceOfServices,
@@ -97,7 +67,9 @@ describe("tests EditServiceCard component", () => {
const wrapper = mount(EditServiceCard, {
global: {
plugins: [store]
mocks: {
$store: store
}
},
props: {
serviceOfServices,
@@ -118,7 +90,9 @@ describe("tests EditServiceCard component", () => {
const wrapper = mount(EditServiceCard, {
global: {
plugins: [store]
mocks: {
$store: store
}
},
props: {
serviceOfServices,
@@ -128,13 +102,13 @@ describe("tests EditServiceCard component", () => {
const selectedService = store.getters['services/selectedService']
expect(selectedService.is_online).toEqual(true)
expect(selectedService.isOnline).toEqual(true)
wrapper.vm.editData({key: 'is_online', value: false})
wrapper.vm.editData({key: 'isOnline', value: false})
const selectedServiceAfterEditing = store.getters['services/selectedService']
expect(selectedServiceAfterEditing.is_online).toEqual(false)
expect(selectedServiceAfterEditing.isOnline).toEqual(false)
})
test("Set isSaveData for selected service in EditServiceCard", async () => {
@@ -143,7 +117,9 @@ describe("tests EditServiceCard component", () => {
const wrapper = mount(EditServiceCard, {
global: {
plugins: [store]
mocks: {
$store: store
}
},
props: {
serviceOfServices,

View File

@@ -10,10 +10,10 @@ import ServiceOfServices from '@services/serviceOfServices/Services.js'
import AdapterOfUsers from '@adapters/adapterOfUsers/Users'
import ServiceOfUsers from '@services/serviceOfUsers/Users.js'
import CaseOfUsersInService from '@useCases/CaseOfUsersInService.js'
import {defaultServices, resServices} from "@mocks/services"
vi.mock('axios')
describe("tests Service Card component", () => {
const store = createStore({
plugins: [],
@@ -23,38 +23,6 @@ describe("tests Service Card component", () => {
},
})
const defaultServices = [
{
"id": 1,
"created_at": "2024-03-06T17:31:31.948355541+03:00",
"updated_at": "2024-03-06T17:31:31.948355541+03:00",
"deleted_at": null,
"name": "jsonplaceholder.typicode.com",
"port": 9965,
"proxy_ip": "172.25.78.153",
"site_ip": "https://jsonplaceholder.typicode.com/",
"internet_uri": "localhost",
"description": "localhost",
"is_online": true
},
]
const resServices = [
{
"id": 1,
"createdAt": "2024-03-06T17:31:31.948355541+03:00",
"updatedAt": "2024-03-06T17:31:31.948355541+03:00",
"deletedAt": null,
"name": "jsonplaceholder.typicode.com",
"port": 9965,
"proxyIp": "172.25.78.153",
"deviceIp": "https://jsonplaceholder.typicode.com/",
"internetUri": "localhost",
"description": "localhost",
"isOnline": true
},
]
axios.get.mockResolvedValue({
data: defaultServices,
})
@@ -76,7 +44,9 @@ describe("tests Service Card component", () => {
test('Service Card mounted with vuex', async () => {
const wrapper = mount(ServiceCard, {
global: {
plugins: [store]
mocks: {
$store: store
}
},
props: {
serviceOfServices,
@@ -105,7 +75,9 @@ describe("tests Service Card component", () => {
const wrapper = mount(ServiceCard, {
global: {
plugins: [store]
mocks: {
$store: store
}
},
props: {
serviceOfServices,
@@ -130,7 +102,9 @@ describe("tests Service Card component", () => {
const wrapper = mount(ServiceCard, {
global: {
plugins: [store]
mocks: {
$store: store
}
},
props: {
serviceOfServices,
@@ -160,7 +134,9 @@ describe("tests Service Card component", () => {
const wrapper = mount(ServiceCard, {
global: {
plugins: [store]
mocks: {
$store: store
}
},
props: {
serviceOfServices,
@@ -184,7 +160,9 @@ describe("tests Service Card component", () => {
const wrapper = mount(ServiceCard, {
global: {
plugins: [store]
mocks: {
$store: store
}
},
props: {
serviceOfServices,
@@ -228,7 +206,9 @@ describe("tests Service Card component", () => {
const wrapper = mount(ServiceCard, {
global: {
plugins: [store]
mocks: {
$store: store
}
},
props: {
caseOfUsersInService
@@ -261,7 +241,9 @@ describe("tests Service Card component", () => {
const wrapper = mount(ServiceCard, {
global: {
plugins: [store]
mocks: {
$store: store
}
},
props: {
serviceOfServices,

View File

@@ -11,10 +11,10 @@ import ServiceOfServices from '@services/serviceOfServices/Services.js'
import AdapterOfUsers from '@adapters/adapterOfUsers/Users'
import ServiceOfUsers from '@services/serviceOfUsers/Users.js'
import CaseOfUsersInService from '@useCases/CaseOfUsersInService.js'
import {defaultServices, resServices} from "@mocks/services"
vi.mock('axios')
describe("tests Services List component", () => {
const store = createStore({
plugins: [],
@@ -24,90 +24,6 @@ describe("tests Services List component", () => {
},
})
const defaultServices = [
{
"id": 1,
"created_at": "2024-03-06T17:31:31.948355541+03:00",
"updated_at": "2024-03-06T17:31:31.948355541+03:00",
"deleted_at": null,
"name": "jsonplaceholder.typicode.com",
"port": 9965,
"proxy_ip": "172.25.78.153",
"site_ip": "https://jsonplaceholder.typicode.com/",
"internet_uri": "localhost",
"description": "localhost",
"is_online": true
},
{
"id": 2,
"created_at": "2024-03-07T11:43:51.026265459+03:00",
"updated_at": "2024-03-07T13:35:12.506368972+03:00",
"deleted_at": null,
"name": "new 2",
"port": 4548,
"proxy_ip": "172.25.78.151",
"site_ip": "172.25.78.151",
"internet_uri": "",
"description": "new site 2",
"is_online": true
},
{
"id": 3,
"created_at": "2024-03-07T11:43:51.027148541+03:00",
"updated_at": "2024-03-07T13:35:24.919273428+03:00",
"deleted_at": null,
"name": "new 3",
"port": 2527,
"proxy_ip": "172.25.78.151",
"site_ip": "172.25.78.151",
"internet_uri": "",
"description": "new site 3...",
"is_online": true
}
]
const resServices = [
{
"id": 1,
"createdAt": "2024-03-06T17:31:31.948355541+03:00",
"updatedAt": "2024-03-06T17:31:31.948355541+03:00",
"deletedAt": null,
"name": "jsonplaceholder.typicode.com",
"port": 9965,
"proxyIp": "172.25.78.153",
"deviceIp": "https://jsonplaceholder.typicode.com/",
"internetUri": "localhost",
"description": "localhost",
"isOnline": true
},
{
"id": 2,
"createdAt": "2024-03-07T11:43:51.026265459+03:00",
"updatedAt": "2024-03-07T13:35:12.506368972+03:00",
"deletedAt": null,
"name": "new 2",
"port": 4548,
"proxyIp": "172.25.78.151",
"deviceIp": "172.25.78.151",
"internetUri": "",
"description": "new site 2",
"isOnline": true
},
{
"id": 3,
"createdAt": "2024-03-07T11:43:51.027148541+03:00",
"updatedAt": "2024-03-07T13:35:24.919273428+03:00",
"deletedAt": null,
"name": "new 3",
"port": 2527,
"proxyIp": "172.25.78.151",
"deviceIp": "172.25.78.151",
"internetUri": "",
"description": "new site 3...",
"isOnline": true
}
]
axios.get.mockResolvedValue({
data: defaultServices,
})
@@ -124,7 +40,9 @@ describe("tests Services List component", () => {
test('Services List mounted with vuex', async () => {
const wrapper = mount(ServicesList, {
global: {
plugins: [store]
mocks: {
$store: store
}
},
props: {
serviceOfServices,