Skip to content

Commit

Permalink
add test case with new lines
Browse files Browse the repository at this point in the history
  • Loading branch information
mrm007 committed Oct 12, 2023
1 parent c38f1de commit 1d3f33a
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
43 changes: 42 additions & 1 deletion packages/source.macro/__snapshots__/source.macro.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,48 @@ const foo = 'bar';
`;

exports[`source.macro 4. code only: 4. code only 1`] = `
exports[`source.macro 4. with new lines: 4. with new lines 1`] = `
import source from './source.macro';
const options = source(() => {
sideEffect();
return [
{ value: "1", label: "Option 1" },
{ value: "2", label: "Option 2" },
{ value: "3", label: "Option 3" },
];
});
↓ ↓ ↓ ↓ ↓ ↓
const options = {
code: '() => {\\n sideEffect();\\n\\n return [\\n { value: "1", label: "Option 1" },\\n { value: "2", label: "Option 2" },\\n { value: "3", label: "Option 3" }];\\n\\n}',
value: () => {
sideEffect();
return [
{
value: '1',
label: 'Option 1',
},
{
value: '2',
label: 'Option 2',
},
{
value: '3',
label: 'Option 3',
},
];
},
};
`;

exports[`source.macro 5. code only: 5. code only 1`] = `
import source from './source.macro';
Expand Down
15 changes: 15 additions & 0 deletions packages/source.macro/source.macro.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ pluginTester({
const foo = 'bar';
`,
},
'with new lines': {
code: /* ts */ `
import source from './source.macro';
const options = source(() => {
sideEffect();
return [
{ value: "1", label: "Option 1" },
{ value: "2", label: "Option 2" },
{ value: "3", label: "Option 3" },
];
});
`,
},
'code only': {
pluginOptions: { source: { codeOnly: true } },
code: /* ts */ `
Expand Down

0 comments on commit 1d3f33a

Please sign in to comment.