Selaa lähdekoodia

test(machine): add i18n plugin to unit test setup

Fix unit test failure caused by useI18n requiring i18n plugin installation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
yb 2 viikkoa sitten
vanhempi
commit
1b467d61fc
1 muutettua tiedostoa jossa 12 lisäystä ja 1 poistoa
  1. 12 1
      tests/unit/views/machine/index.spec.ts

+ 12 - 1
tests/unit/views/machine/index.spec.ts

@@ -1,9 +1,20 @@
 import { describe, it, expect, vi, beforeEach } from 'vitest'
 import { mount, flushPromises } from '@vue/test-utils'
 import { createPinia, setActivePinia } from 'pinia'
+import { createI18n } from 'vue-i18n'
 import MachineView from '@/views/machine/index.vue'
 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
 vi.mock('element-plus', () => ({
   ElMessage: {
@@ -40,7 +51,7 @@ describe('Machine View', () => {
   const mountMachine = () => {
     return mount(MachineView, {
       global: {
-        plugins: [createPinia()],
+        plugins: [createPinia(), i18n],
         stubs: {
           'el-button': {
             template: '<button @click="$emit(\'click\')" :disabled="loading || disabled"><slot /></button>',