/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
packages/mui-codemod/src/util/findComponentJSX.test.js
49 строк
2 KB
Siriwat K
[codemod] Add package name option (#45977)
12 май 2025, 04:42
Не верифицирован
12 май 2025, 04:42
9f4df51
Код
Авторство
О чём код?
import { expect } from 'chai'; import findComponentJSX from './findComponentJSX'; import { jscodeshift } from '../../testUtils'; describe('@mui/codemod', () => { describe('utils', () => { describe('findComponentJSX', () => { it('should find all the JSXElements of a given component name', () => { const j = jscodeshift; const root = j(` import { Accordion } from '@mui/material'; // ✅ import Accordion2 from '@mui/material/Accordion'; // ✅ import Accordion3 from '@mui/material/Accordion3'; // ❌ <Accordion />; <Accordion2 />; <Accordion3 />; `); const componentName = 'Accordion'; const foundElements = []; findComponentJSX(j, { root, componentName }, (path) => { foundElements.push(path); }); expect(foundElements.length).to.equal(2); }); it('should find with custom package name', () => { const j = jscodeshift; const root = j(` import { Accordion } from '@org/ui/material'; // ✅ import Accordion2 from '@org/ui/material/Accordion'; // ✅ import Accordion3 from '@org/ui/material/Accordion3'; // ❌ <Accordion />; <Accordion2 />; <Accordion3 />; `); const componentName = 'Accordion'; const foundElements = []; findComponentJSX(j, { root, componentName, packageName: '@org/ui/material' }, (path) => { foundElements.push(path); }); expect(foundElements.length).to.equal(2); }); }); }); });