mirror of
https://github.com/johndoe6345789/docker-swarm-termina.git
synced 2026-04-24 13:45:01 +00:00
Install testing dependencies: - Jest and jest-environment-jsdom for test runner - React Testing Library for component testing - @testing-library/user-event for user interaction simulation - @types/jest for TypeScript support Configure Jest: - Next.js Jest configuration with jsdom environment - Mock window.matchMedia, localStorage, and fetch - Setup test paths and coverage collection Add test coverage: - Utility functions (terminal formatPrompt and highlightCommand) - Redux store (authSlice async thunks and reducers) - Custom hooks (useLoginForm, useAuthRedirect, useTerminalModal) - React components (LoginForm, TerminalHeader, ContainerHeader, ContainerInfo, EmptyState) Test results: 59 tests passing across 10 test suites https://claude.ai/code/session_G4kZm
29 lines
621 B
JavaScript
29 lines
621 B
JavaScript
import '@testing-library/jest-dom'
|
|
|
|
// Mock window.matchMedia
|
|
Object.defineProperty(window, 'matchMedia', {
|
|
writable: true,
|
|
value: jest.fn().mockImplementation(query => ({
|
|
matches: false,
|
|
media: query,
|
|
onchange: null,
|
|
addListener: jest.fn(),
|
|
removeListener: jest.fn(),
|
|
addEventListener: jest.fn(),
|
|
removeEventListener: jest.fn(),
|
|
dispatchEvent: jest.fn(),
|
|
})),
|
|
})
|
|
|
|
// Mock localStorage
|
|
const localStorageMock = {
|
|
getItem: jest.fn(),
|
|
setItem: jest.fn(),
|
|
removeItem: jest.fn(),
|
|
clear: jest.fn(),
|
|
}
|
|
global.localStorage = localStorageMock
|
|
|
|
// Mock fetch
|
|
global.fetch = jest.fn()
|