Initial commit
This commit is contained in:
65
users-manage/tests/views/5_pages/SitesList.test.js
Normal file
65
users-manage/tests/views/5_pages/SitesList.test.js
Normal file
@@ -0,0 +1,65 @@
|
||||
import { mount} from '@vue/test-utils'
|
||||
import { expect, test, describe, vi } from 'vitest'
|
||||
import Sites from '@pages/SitesManagerPage/SitesManagerPage.vue';
|
||||
import { createStore } from 'vuex'
|
||||
import {store as services} from '@/store/modules/services';
|
||||
import {store as users} from '@/store/modules/users';
|
||||
import axios from "axios";
|
||||
|
||||
vi.mock('axios')
|
||||
|
||||
describe("tests SitesManagerPage component mounted with vuex", () => {
|
||||
const store = createStore({
|
||||
plugins: [],
|
||||
modules: {
|
||||
services,
|
||||
users
|
||||
},
|
||||
})
|
||||
|
||||
const mockData = [
|
||||
{
|
||||
"id": 1,
|
||||
"first_name": "Leanne",
|
||||
"last_name": "Graham",
|
||||
"email": "test@mail.ru",
|
||||
"role": "admin",
|
||||
"is_active": true
|
||||
}
|
||||
]
|
||||
|
||||
axios.get.mockResolvedValue({
|
||||
data: mockData,
|
||||
})
|
||||
|
||||
|
||||
test('tests App mounted with vuex', async () => {
|
||||
const wrapper = mount(Sites, {
|
||||
shallow: true,
|
||||
global: {
|
||||
plugins: [store]
|
||||
}
|
||||
})
|
||||
|
||||
const siteId = 1
|
||||
const answer = await wrapper.vm.selectSite(siteId, "production")
|
||||
|
||||
const usersList = store.getters['users/usersList']
|
||||
const componentState = store.getters['users/componentState']
|
||||
const selectedService = store.getters['services/selectedService']
|
||||
|
||||
expect(usersList).toEqual([{
|
||||
"id": 1,
|
||||
"first_name": "Leanne",
|
||||
"last_name": "Graham",
|
||||
"email": "test@mail.ru",
|
||||
"role": "admin",
|
||||
"is_active": true
|
||||
}])
|
||||
expect(componentState).toEqual('active')
|
||||
expect(selectedService).not.toBe(null)
|
||||
expect(answer).toBe("ok")
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user