/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
packages/mui-codemod/testUtils/index.js
52 строки
1 KB
Brijesh Bittu
[code-infra] Enable testing-library eslint rules (#47074)
15 окт 2025, 10:45
Не верифицирован
15 окт 2025, 10:45
a9dab8b
Код
Авторство
О чём код?
/* eslint-disable no-undef */ import j from 'jscodeshift'; import { EOL } from 'os'; import path from 'path'; import { expect } from 'chai'; import readFile from '../src/util/readFile'; export const jscodeshift = j.withParser('tsx'); function read(dirname, fileName) { return readFile(path.join(dirname, fileName)); } export function describeJscodeshiftTransform({ transformName, transform, testCases, dirname }) { describe(transformName, () => { testCases.forEach((testCase) => { it('transforms as needed', () => { const actual = transform( { source: read(dirname, testCase.actual) }, { jscodeshift }, { ...testCase.options, printOptions: { ...testCase.options?.printOptions, lineTerminator: EOL, }, }, ); const expected = read(dirname, testCase.expected); expect(actual).to.equal(expected, 'The transformed version should be correct'); }); it('should be idempotent', () => { const actual = transform( { source: read(dirname, testCase.expected) }, { jscodeshift }, { ...testCase.options, printOptions: { ...testCase.options?.printOptions, lineTerminator: EOL, }, }, ); const expected = read(dirname, testCase.expected); expect(actual).to.equal(expected, 'The transformed version should be correct'); }); }); }); }