57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
JavaScript
import { mount} from '@vue/test-utils'
|
|
import { expect, test, describe, vi, beforeEach } from 'vitest'
|
|
import UsersManagerUserEditor from '@organisms/UsersManager/UsersManagerUserEditor.vue';
|
|
import { createStore } from 'vuex'
|
|
import {store as users} from '@/store/modules/users';
|
|
import axios from "axios";
|
|
|
|
vi.mock('axios')
|
|
|
|
describe("tests UsersManagerUserEditor component mounted with vuex", () => {
|
|
const store = createStore({
|
|
plugins: [],
|
|
modules: {
|
|
users
|
|
},
|
|
})
|
|
|
|
beforeEach( async () => {
|
|
store.dispatch('users/resetStore')
|
|
|
|
const mockData = [
|
|
{
|
|
"id": 1,
|
|
"created_at": "2024-02-22T17:08:37.715772388+03:00",
|
|
"updated_at": "2024-02-26T14:11:38.64094899+03:00",
|
|
"deleted_at": null,
|
|
"name": "jsonplaceholder.typicode.com",
|
|
"port": 9965,
|
|
"proxy_ip": "172.25.78.153",
|
|
"site_ip": "172.25.78.153",
|
|
"internet_uri": "localhost",
|
|
"description": "localhost",
|
|
"is_online": true
|
|
}
|
|
]
|
|
axios.get.mockResolvedValue({
|
|
data: mockData,
|
|
})
|
|
await store.dispatch('services/uploadSites')
|
|
|
|
store.dispatch('services/uploadAndSelectService', 1)
|
|
})
|
|
|
|
test('tests UsersManager mounted with vuex', async () => {
|
|
const wrapper = mount(UsersManagerUserEditor, {
|
|
shallow: true,
|
|
global: {
|
|
plugins: [store]
|
|
}
|
|
})
|
|
|
|
expect(wrapper.exists()).toBe(true)
|
|
})
|
|
})
|
|
|
|
|