|
| 1 | +import path from 'path'; |
| 2 | +import { expect } from 'chai'; |
| 3 | +import { jscodeshift } from '../../../testUtils'; |
| 4 | +import transform from './step-content-props'; |
| 5 | +import readFile from '../../util/readFile'; |
| 6 | + |
| 7 | +function read(fileName) { |
| 8 | + return readFile(path.join(__dirname, fileName)); |
| 9 | +} |
| 10 | + |
| 11 | +describe('@mui/codemod', () => { |
| 12 | + describe('deprecations', () => { |
| 13 | + describe('step-content-props', () => { |
| 14 | + it('transforms props as needed', () => { |
| 15 | + const actual = transform({ source: read('./test-cases/actual.js') }, { jscodeshift }, {}); |
| 16 | + |
| 17 | + const expected = read('./test-cases/expected.js'); |
| 18 | + expect(actual).to.equal(expected, 'The transformed version should be correct'); |
| 19 | + }); |
| 20 | + |
| 21 | + it('should be idempotent', () => { |
| 22 | + const actual = transform({ source: read('./test-cases/expected.js') }, { jscodeshift }, {}); |
| 23 | + |
| 24 | + const expected = read('./test-cases/expected.js'); |
| 25 | + expect(actual).to.equal(expected, 'The transformed version should be correct'); |
| 26 | + }); |
| 27 | + }); |
| 28 | + |
| 29 | + describe('[theme] step-content-props', () => { |
| 30 | + it('transforms props as needed', () => { |
| 31 | + const actual = transform( |
| 32 | + { source: read('./test-cases/theme.actual.js') }, |
| 33 | + { jscodeshift }, |
| 34 | + {}, |
| 35 | + ); |
| 36 | + |
| 37 | + const expected = read('./test-cases/theme.expected.js'); |
| 38 | + expect(actual).to.equal(expected, 'The transformed version should be correct'); |
| 39 | + }); |
| 40 | + |
| 41 | + it('should be idempotent', () => { |
| 42 | + const actual = transform( |
| 43 | + { source: read('./test-cases/theme.expected.js') }, |
| 44 | + { jscodeshift }, |
| 45 | + {}, |
| 46 | + ); |
| 47 | + |
| 48 | + const expected = read('./test-cases/theme.expected.js'); |
| 49 | + expect(actual).to.equal(expected, 'The transformed version should be correct'); |
| 50 | + }); |
| 51 | + }); |
| 52 | + }); |
| 53 | +}); |
0 commit comments