Skip to content

Commit

Permalink
fixed static variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldpipowitch committed Dec 5, 2019
1 parent 53bbea1 commit e7bac24
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@prisma-capacity/babel-plugin-react-display-name",
"version": "1.0.2",
"version": "1.0.3",
"description": "Automatically add displayName properties to your React project.",
"main": "dist/index.js",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function({ types: t }: typeof babel): PluginObj {
t.assignmentExpression(
'=',
t.memberExpression(
t.identifier('Hello'),
t.identifier(path.node.id.name),
t.identifier('displayName')
),
t.stringLiteral(path.node.id.name)
Expand Down
24 changes: 12 additions & 12 deletions tests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,54 +11,54 @@ function run(source: string) {

test('handle "FC" type reference', () => {
const source = `
const Hello: FC = () => null;
const Hello1: FC = () => null;
`;

expect(run(source)).toMatchInlineSnapshot(`
"\\"use strict\\";
const Hello = () => null;
const Hello1 = () => null;
Hello.displayName = \\"Hello\\";"
Hello1.displayName = \\"Hello1\\";"
`);
});

test('handle "FunctionComponent" type reference', () => {
const source = `
const Hello: FunctionComponent = () => null;
const Hello2: FunctionComponent = () => null;
`;

expect(run(source)).toMatchInlineSnapshot(`
"\\"use strict\\";
const Hello = () => null;
const Hello2 = () => null;
Hello.displayName = \\"Hello\\";"
Hello2.displayName = \\"Hello2\\";"
`);
});

test('handle "forwardRef" usage', () => {
const source = `
const Hello = forwardRef(() => null);
const Hello3 = forwardRef(() => null);
`;

expect(run(source)).toMatchInlineSnapshot(`
"\\"use strict\\";
const Hello = forwardRef(() => null);
Hello.displayName = \\"Hello\\";"
const Hello3 = forwardRef(() => null);
Hello3.displayName = \\"Hello3\\";"
`);
});

test('handle "memo" usage', () => {
const source = `
const Hello = memo(() => null);
const Hello4 = memo(() => null);
`;

expect(run(source)).toMatchInlineSnapshot(`
"\\"use strict\\";
const Hello = memo(() => null);
Hello.displayName = \\"Hello\\";"
const Hello4 = memo(() => null);
Hello4.displayName = \\"Hello4\\";"
`);
});

0 comments on commit e7bac24

Please sign in to comment.