refactor: create shared react-i18next mock to reduce duplication (#29711)

This commit is contained in:
yyh
2025-12-16 12:45:17 +08:00
committed by GitHub
parent 4cc6652424
commit eeb5129a17
40 changed files with 58 additions and 228 deletions

View File

@ -3,13 +3,6 @@ import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import { AppModeEnum } from '@/types/app'
import { AccessMode } from '@/models/access-control'
// Mock react-i18next - return key as per testing skills
jest.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string) => key,
}),
}))
// Mock next/navigation
const mockPush = jest.fn()
jest.mock('next/navigation', () => ({

View File

@ -2,13 +2,6 @@ import React from 'react'
import { render, screen } from '@testing-library/react'
import Empty from './empty'
// Mock react-i18next - return key as per testing skills
jest.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string) => key,
}),
}))
describe('Empty', () => {
beforeEach(() => {
jest.clearAllMocks()

View File

@ -2,13 +2,6 @@ import React from 'react'
import { render, screen } from '@testing-library/react'
import Footer from './footer'
// Mock react-i18next - return key as per testing skills
jest.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string) => key,
}),
}))
describe('Footer', () => {
beforeEach(() => {
jest.clearAllMocks()

View File

@ -1,13 +1,6 @@
import React from 'react'
import { render, screen } from '@testing-library/react'
// Mock react-i18next - return key as per testing skills
jest.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string) => key,
}),
}))
// Track mock calls
let documentTitleCalls: string[] = []
let educationInitCalls: number = 0

View File

@ -2,13 +2,6 @@ import React from 'react'
import { fireEvent, render, screen } from '@testing-library/react'
import { AppModeEnum } from '@/types/app'
// Mock react-i18next - return key as per testing skills
jest.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string) => key,
}),
}))
// Mock next/navigation
const mockReplace = jest.fn()
const mockRouter = { replace: mockReplace }

View File

@ -1,13 +1,6 @@
import React from 'react'
import { fireEvent, render, screen } from '@testing-library/react'
// Mock react-i18next - return key as per testing skills
jest.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string) => key,
}),
}))
// Mock next/navigation
const mockReplace = jest.fn()
jest.mock('next/navigation', () => ({