File tree Expand file tree Collapse file tree 3 files changed +28
-8
lines changed Expand file tree Collapse file tree 3 files changed +28
-8
lines changed Original file line number Diff line number Diff line change 11import { applyTransform } from '@codeshift/test-utils' ;
22import * as transformer from './transform' ;
3+ import prettier from 'prettier' ;
4+
5+ function format ( source : string ) : string {
6+ return prettier . format ( source , { parser : 'typescript' } ) . trim ( ) ;
7+ }
38
49describe ( 'memoize-one@5.0.0 transform' , ( ) => {
5- it ( 'should transform correctly ' , ( ) => {
10+ it ( 'should not touch usages that do not use a custom equality function ' , ( ) => {
611 const result = applyTransform (
712 transformer ,
8- `
9- import foo from '<% packageName %>';
10- console.log(foo);
11- ` ,
13+ format ( `
14+ import memoize from 'memoize-one';
15+
16+ function add(a: number, b: number) {
17+ return a + b;
18+ }
19+
20+ const memoized = memoize(add);
21+ ` ) ,
1222 { parser : 'tsx' } ,
1323 ) ;
1424
15- expect ( result ) . toMatchInlineSnapshot ( ) ;
25+ expect ( result ) . toEqual (
26+ format ( `
27+ import memoize from 'memoize-one';
28+
29+ function add(a: number, b: number) {
30+ return a + b;
31+ }
32+
33+ const memoized = memoize(add);
34+ ` ) ,
35+ ) ;
1636 } ) ;
1737} ) ;
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export default function transformer(
1515 * See this page for more information:
1616 * https://codeshiftcommunity.github.io/CodeshiftCommunity/docs/your-first-codemod#output
1717 */
18- if ( /* Some condition here */ true ) {
18+ if ( true ) {
1919 return file . source ;
2020 }
2121
Original file line number Diff line number Diff line change @@ -2,6 +2,6 @@ module.exports = {
22 maintainers : [ ] ,
33 target : [ ] ,
44 description : 'Codemods for memoize-one' ,
5- transforms : { '5.0.0' : require . resolve ( './5.0.0/transform' ) , } ,
5+ transforms : { '5.0.0' : require . resolve ( './5.0.0/transform' ) } ,
66 presets : { } ,
77} ;
You can’t perform that action at this time.
0 commit comments