|
@@ -1,9 +1,20 @@
|
|
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
|
|
import { mount, flushPromises } from '@vue/test-utils'
|
|
import { mount, flushPromises } from '@vue/test-utils'
|
|
|
import { createPinia, setActivePinia } from 'pinia'
|
|
import { createPinia, setActivePinia } from 'pinia'
|
|
|
|
|
+import { createI18n } from 'vue-i18n'
|
|
|
import MachineView from '@/views/machine/index.vue'
|
|
import MachineView from '@/views/machine/index.vue'
|
|
|
import { wrapResponse, mockMachines } from '../../../fixtures'
|
|
import { wrapResponse, mockMachines } from '../../../fixtures'
|
|
|
|
|
|
|
|
|
|
+// Create i18n instance for tests
|
|
|
|
|
+const i18n = createI18n({
|
|
|
|
|
+ legacy: false,
|
|
|
|
|
+ locale: 'zh-cn',
|
|
|
|
|
+ messages: {
|
|
|
|
|
+ 'zh-cn': {},
|
|
|
|
|
+ en: {}
|
|
|
|
|
+ }
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
// Mock element-plus
|
|
// Mock element-plus
|
|
|
vi.mock('element-plus', () => ({
|
|
vi.mock('element-plus', () => ({
|
|
|
ElMessage: {
|
|
ElMessage: {
|
|
@@ -40,7 +51,7 @@ describe('Machine View', () => {
|
|
|
const mountMachine = () => {
|
|
const mountMachine = () => {
|
|
|
return mount(MachineView, {
|
|
return mount(MachineView, {
|
|
|
global: {
|
|
global: {
|
|
|
- plugins: [createPinia()],
|
|
|
|
|
|
|
+ plugins: [createPinia(), i18n],
|
|
|
stubs: {
|
|
stubs: {
|
|
|
'el-button': {
|
|
'el-button': {
|
|
|
template: '<button @click="$emit(\'click\')" :disabled="loading || disabled"><slot /></button>',
|
|
template: '<button @click="$emit(\'click\')" :disabled="loading || disabled"><slot /></button>',
|