-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit '65ca2086efbeb526b734db560a8e19f833562aa5' into vitest-x…
…-browser-working
- Loading branch information
Showing
19 changed files
with
293 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/x-codemod/src/v8.0.0/pickers/preset-safe/actual.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @ts-nocheck | ||
import { FieldValueType } from '@mui/x-date-pickers/models'; | ||
|
||
interface DumbComponentProps { | ||
valueType: FieldValueType; | ||
foo: string; | ||
bar: number; | ||
} | ||
|
||
const myFunction = (param: FieldValueType) => { | ||
console.log('Hello World!'); | ||
}; |
12 changes: 12 additions & 0 deletions
12
packages/x-codemod/src/v8.0.0/pickers/preset-safe/expected.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @ts-nocheck | ||
import { PickerValueType } from '@mui/x-date-pickers/models'; | ||
|
||
interface DumbComponentProps { | ||
valueType: PickerValueType; | ||
foo: string; | ||
bar: number; | ||
} | ||
|
||
const myFunction = (param: PickerValueType) => { | ||
console.log('Hello World!'); | ||
}; |
41 changes: 41 additions & 0 deletions
41
packages/x-codemod/src/v8.0.0/pickers/preset-safe/preset-safe.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import path from 'path'; | ||
import { expect } from 'chai'; | ||
import jscodeshift from 'jscodeshift'; | ||
import transform from './index'; | ||
import readFile from '../../../util/readFile'; | ||
|
||
function read(fileName) { | ||
return readFile(path.join(__dirname, fileName)); | ||
} | ||
|
||
describe('v8.0.0/pickers', () => { | ||
describe('preset-safe', () => { | ||
it('transforms code as needed', () => { | ||
const actual = transform( | ||
{ | ||
source: read('./actual.spec.tsx'), | ||
path: require.resolve('./actual.spec.tsx'), | ||
}, | ||
{ jscodeshift: jscodeshift.withParser('tsx') }, | ||
{}, | ||
); | ||
|
||
const expected = read('./expected.spec.tsx'); | ||
expect(actual).to.equal(expected, 'The transformed version should be correct'); | ||
}); | ||
|
||
it('should be idempotent for expression', () => { | ||
const actual = transform( | ||
{ | ||
source: read('./expected.spec.tsx'), | ||
path: require.resolve('./expected.spec.tsx'), | ||
}, | ||
{ jscodeshift: jscodeshift.withParser('tsx') }, | ||
{}, | ||
); | ||
|
||
const expected = read('./expected.spec.tsx'); | ||
expect(actual).to.equal(expected, 'The transformed version should be correct'); | ||
}); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
packages/x-codemod/src/v8.0.0/preset-safe/expected.spec.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 42 additions & 11 deletions
53
packages/x-codemod/src/v8.0.0/preset-safe/preset-safe.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,58 @@ | ||
import path from 'path'; | ||
import { expect } from 'chai'; | ||
import jscodeshift from 'jscodeshift'; | ||
import fs from 'fs'; | ||
import transform from '.'; | ||
import readFile from '../../util/readFile'; | ||
|
||
function read(fileName) { | ||
return readFile(path.join(__dirname, fileName)); | ||
return readFile(fileName); | ||
} | ||
|
||
function getAllDirs() { | ||
return fs | ||
.readdirSync(path.resolve(__dirname, '..')) | ||
.filter( | ||
(file) => | ||
fs.statSync(path.resolve(__dirname, '..', file)).isDirectory() && file !== 'preset-safe', | ||
); | ||
} | ||
|
||
describe('v8.0.0', () => { | ||
describe('preset-safe', () => { | ||
it('transforms code as needed', () => { | ||
const actual = transform({ source: read('./actual.spec.js') }, { jscodeshift }, {}); | ||
const MOD_DIRS = getAllDirs(); | ||
|
||
const expected = read('./expected.spec.js'); | ||
expect(actual).to.equal(expected, 'The transformed version should be correct'); | ||
}); | ||
describe('preset-safe', () => { | ||
MOD_DIRS.forEach((testDir) => { | ||
const actualPath = path.resolve(__dirname, '..', testDir, 'preset-safe', 'actual.spec.tsx'); | ||
const expectedPath = path.resolve( | ||
__dirname, | ||
'..', | ||
testDir, | ||
'preset-safe', | ||
'expected.spec.tsx', | ||
); | ||
|
||
it('should be idempotent', () => { | ||
const actual = transform({ source: read('./expected.spec.js') }, { jscodeshift }, {}); | ||
describe(`${testDir.replace(/-/g, ' ')}`, () => { | ||
it('transforms code as needed', () => { | ||
const actual = transform( | ||
{ source: read(actualPath) }, | ||
{ jscodeshift: jscodeshift.withParser('tsx') }, | ||
{}, | ||
); | ||
const expected = read(expectedPath); | ||
expect(actual).to.equal(expected, 'The transformed version should be correct'); | ||
}); | ||
|
||
const expected = read('./expected.spec.js'); | ||
expect(actual).to.equal(expected, 'The transformed version should be correct'); | ||
it('should be idempotent', () => { | ||
const actual = transform( | ||
{ source: read(expectedPath) }, | ||
{ jscodeshift: jscodeshift.withParser('tsx') }, | ||
{}, | ||
); | ||
const expected = read(expectedPath); | ||
expect(actual).to.equal(expected, 'The transformed version should be correct'); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.