Skip to content

Commit c4ddc61

Browse files
tests: add tests for different line endings (#2315)
1 parent a09c973 commit c4ddc61

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

packages/babel-plugin-lingui-macro/test/__snapshots__/jsx-trans.test.ts.snap

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,45 @@ import { Trans as _Trans } from "@lingui/react";
446446
447447
`;
448448
449+
exports[`Produce the same ID regardless of CRLF, LF, and CR line endings 1`] = `
450+
import { Trans } from "@lingui/react/macro";
451+
<Trans>hello</Trans>;
452+
<Trans>hello</Trans>;
453+
<Trans>hello</Trans>;
454+
455+
↓ ↓ ↓ ↓ ↓ ↓
456+
457+
import { Trans as _Trans } from "@lingui/react";
458+
<_Trans
459+
{
460+
/*i18n*/
461+
...{
462+
id: "WfCysZ",
463+
message: "hello",
464+
}
465+
}
466+
/>;
467+
<_Trans
468+
{
469+
/*i18n*/
470+
...{
471+
id: "WfCysZ",
472+
message: "hello",
473+
}
474+
}
475+
/>;
476+
<_Trans
477+
{
478+
/*i18n*/
479+
...{
480+
id: "WfCysZ",
481+
message: "hello",
482+
}
483+
}
484+
/>;
485+
486+
`;
487+
449488
exports[`Production - all props kept if extract: true 1`] = `
450489
import { Trans } from "@lingui/react/macro";
451490
<Trans id="msg.hello" comment="Hello World">

packages/babel-plugin-lingui-macro/test/jsx-trans.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,14 @@ macroTester({
273273
</Trans>
274274
`,
275275
},
276+
{
277+
name: "Produce the same ID regardless of CRLF, LF, and CR line endings",
278+
code:
279+
'import { Trans } from "@lingui/react/macro";\n' +
280+
"<Trans>\nhello\n</Trans>;\n" +
281+
"<Trans>\r\nhello\r\n</Trans>;\n" +
282+
"<Trans>\rhello\r</Trans>;\n",
283+
},
276284
{
277285
name: "Keep forced newlines",
278286
filename: "./jsx-keep-forced-newlines.js",

0 commit comments

Comments
 (0)