Skip to content

Commit

Permalink
test cases for arrow function
Browse files Browse the repository at this point in the history
  • Loading branch information
aadito123 committed Feb 1, 2023
1 parent 5310899 commit 9586a77
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/rules/prefer-show.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,51 @@ export const cases = run("prefer-show", rule, {
);
}`,
},
{
code: `
function Component(props) {
return (
<For each={props.someList}>
{(listItem) => listItem.cond && <span>Content</span>}
</For>
);
}`,
errors: [{ messageId: "preferShowAnd" }],
output: `
function Component(props: any) {
return (
<For each={props.someList}>
{(listItem) => <Show when={listItem.cond}><span>Content</span></Show>}
</For>
);
}`,
},
{
code: `
function Component(props) {
return (
<For each={props.someList}>
{(listItem) => (listItem.cond ? (
<span>Content</span>
) : (
<span>Fallback</span>
))}
</For>
);
}`,
errors: [{ messageId: "preferShowTernary" }],
output: `
function Component(props) {
return (
<For each={props.someList}>
{(listItem) => (
<Show when={listItem.cond} fallback={<span>Fallback</span>}>
<span>Content</span>
</Show>
)}
</For>
);
}`,
},
],
});

0 comments on commit 9586a77

Please sign in to comment.