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 1
1
import { applyTransform } from '@codeshift/test-utils' ;
2
2
import * 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
+ }
3
8
4
9
describe ( '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 ' , ( ) => {
6
11
const result = applyTransform (
7
12
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
+ ` ) ,
12
22
{ parser : 'tsx' } ,
13
23
) ;
14
24
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
+ ) ;
16
36
} ) ;
17
37
} ) ;
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export default function transformer(
15
15
* See this page for more information:
16
16
* https://codeshiftcommunity.github.io/CodeshiftCommunity/docs/your-first-codemod#output
17
17
*/
18
- if ( /* Some condition here */ true ) {
18
+ if ( true ) {
19
19
return file . source ;
20
20
}
21
21
Original file line number Diff line number Diff line change @@ -2,6 +2,6 @@ module.exports = {
2
2
maintainers : [ ] ,
3
3
target : [ ] ,
4
4
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' ) } ,
6
6
presets : { } ,
7
7
} ;
You can’t perform that action at this time.
0 commit comments