Skip to content

Commit 9e4e3fe

Browse files
committed
first test passing
1 parent cf5fd25 commit 9e4e3fe

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed
Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,37 @@
11
import { applyTransform } from '@codeshift/test-utils';
22
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+
}
38

49
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', () => {
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
});

community/memoize-one/src/5.0.0/transform.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

community/memoize-one/src/codeshift.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
};

0 commit comments

Comments
 (0)