Skip to content

Commit

Permalink
Fixed a missing test case in #90
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Jul 25, 2018
1 parent c92a8b5 commit 7dd8045
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/parser.js
Expand Up @@ -433,6 +433,12 @@ class Parser {
parseJSXElement(expression);
});

ensureArray(node.children).forEach(childNode => {
if (childNode.type === 'JSXElement') {
parseJSXElement(childNode);
}
});

if (node.openingElement.name.name !== component) {
return;
}
Expand Down
32 changes: 28 additions & 4 deletions test/fixtures/trans.jsx
@@ -1,8 +1,6 @@
import { Fragment } from 'react';

const Component = (props) => props.children;

const mycomp = () => (
const Component = () => (
<Fragment>
<Fragment>
<Trans i18nKey="jsx-quotes-double">Use double quotes for the i18nKey attribute</Trans>
Expand Down Expand Up @@ -112,10 +110,36 @@ const mycomp = () => (
/>
)}
/>
<Tooltip
content={(
<TooltipTextContainer>
<Trans i18nKey="tooltip1" parent={'span'} i18n={i18n} t={t}>
Some tooltip text
</Trans>
</TooltipTextContainer>
)}
>
<InfoIconStyled />
</Tooltip>
<Tooltip
content={(
<TooltipTextContainer>
<AnotherContainer>
<Trans i18nKey="tooltip2" parent={'span'} i18n={i18n} t={t}>
Some tooltip text
</Trans>
</AnotherContainer>
</TooltipTextContainer>
)}
>
<InfoStyleIcon />
</Tooltip>
</Fragment>
<Fragment>
<I18n __t="mykey">A wrapper component with key</I18n>
<I18n>A wrapper component without key</I18n>
</Fragment>
</Fragment>
)
);

export default Component;
8 changes: 6 additions & 2 deletions test/parser.js
Expand Up @@ -153,7 +153,9 @@ test('Parse Trans components', (t) => {
// props
"translation from props": "translation from props",
"translation from nested props": "translation from nested props",
"translation from deeply nested props": "translation from deeply nested props"
"translation from deeply nested props": "translation from deeply nested props",
"tooltip1": "Some tooltip text",
"tooltip2": "Some tooltip text"
}
}
});
Expand Down Expand Up @@ -217,7 +219,9 @@ test('Parse Trans components with fallback key', (t) => {
// props
"c38f91deba88fc3bb582cc73dc658210324b01ec": "translation from props",
"5bf216b4068991e3a2f5e55ae36c03add490a63f": "translation from nested props",
"6fadff01c49d0ebe862a3aa33688735c03728197": "translation from deeply nested props"
"6fadff01c49d0ebe862a3aa33688735c03728197": "translation from deeply nested props",
"tooltip1": "Some tooltip text",
"tooltip2": "Some tooltip text"
}
}
});
Expand Down
4 changes: 3 additions & 1 deletion test/transform-stream.js
Expand Up @@ -217,7 +217,9 @@ test('[Trans Component] fallbackKey', function(t) {
// props
"translation from props": "translation from props",
"translation from nested props": "translation from nested props",
"translation from deeply nested props": "translation from deeply nested props"
"translation from deeply nested props": "translation from deeply nested props",
"tooltip1": "Some tooltip text",
"tooltip2": "Some tooltip text"
};
t.same(found, wanted);
}
Expand Down

0 comments on commit 7dd8045

Please sign in to comment.