refactor(web): migrate to Vitest and esm (#29974)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
This commit is contained in:
Stephen Zhou
2025-12-22 16:35:22 +08:00
committed by GitHub
parent 42f7ecda12
commit eabdc5f0eb
268 changed files with 5455 additions and 6307 deletions

View File

@ -1,13 +1,12 @@
import { fireEvent, render, screen } from '@testing-library/react'
import '@testing-library/jest-dom'
import React from 'react'
import type { IconData } from './IconBase'
import IconBase from './IconBase'
import * as utils from './utils'
// Mock the utils module
jest.mock('./utils', () => ({
generate: jest.fn((icon, key, props) => (
vi.mock('./utils', () => ({
generate: vi.fn((icon, key, props) => (
<svg
data-testid="mock-svg"
key={key}
@ -25,7 +24,7 @@ describe('IconBase Component', () => {
}
beforeEach(() => {
jest.clearAllMocks()
vi.clearAllMocks()
})
it('renders properly with required props', () => {
@ -48,7 +47,7 @@ describe('IconBase Component', () => {
})
it('handles onClick events', () => {
const handleClick = jest.fn()
const handleClick = vi.fn()
render(<IconBase data={mockData} onClick={handleClick} />)
const svg = screen.getByTestId('mock-svg')
fireEvent.click(svg)

View File

@ -1,7 +1,6 @@
import type { AbstractNode } from './utils'
import { generate, normalizeAttrs } from './utils'
import { render } from '@testing-library/react'
import '@testing-library/jest-dom'
describe('generate icon base utils', () => {
describe('normalizeAttrs', () => {
@ -41,7 +40,7 @@ describe('generate icon base utils', () => {
const { container } = render(generate(node, 'key'))
// to svg element
expect(container.firstChild).toHaveClass('container')
expect(container.querySelector('span')).toHaveStyle({ color: 'blue' })
expect(container.querySelector('span')).toHaveStyle({ color: 'rgb(0, 0, 255)' })
})
// add not has children