mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[tests][fixtures] Enable sprout on basic existing fbt tests
---
Output:
```
$ yarn sprout:build && yarn sprout --verbose
...
PASS fbt-call-complex-param-value
ok <div>Hello, Sathya!</div>
PASS fbt-call
ok <div>2 items</div>
PASS fbt-template-string-same-scope
ok <div>{"children":"for 3 experiences"}</div>
...
```
This commit is contained in:
+14
-2
@@ -3,15 +3,21 @@
|
||||
|
||||
```javascript
|
||||
import fbt from "fbt";
|
||||
import { identity } from "shared-runtime";
|
||||
|
||||
function Component(props) {
|
||||
const text = fbt(
|
||||
`Hello, ${fbt.param("(key) name", capitalize(props.name))}!`,
|
||||
`Hello, ${fbt.param("(key) name", identity(props.name))}!`,
|
||||
"(description) Greeting"
|
||||
);
|
||||
return <div>{text}</div>;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{ name: "Sathya" }],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
@@ -19,6 +25,7 @@ function Component(props) {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
import fbt from "fbt";
|
||||
import { identity } from "shared-runtime";
|
||||
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(4);
|
||||
@@ -26,7 +33,7 @@ function Component(props) {
|
||||
if ($[0] !== props.name) {
|
||||
t0 = fbt._(
|
||||
"Hello, {(key) name}!",
|
||||
[fbt._param("(key) name", capitalize(props.name))],
|
||||
[fbt._param("(key) name", identity(props.name))],
|
||||
{ hk: "2sOsn5" }
|
||||
);
|
||||
$[0] = props.name;
|
||||
@@ -46,5 +53,10 @@ function Component(props) {
|
||||
return t1;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{ name: "Sathya" }],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
+7
-1
@@ -1,9 +1,15 @@
|
||||
import fbt from "fbt";
|
||||
import { identity } from "shared-runtime";
|
||||
|
||||
function Component(props) {
|
||||
const text = fbt(
|
||||
`Hello, ${fbt.param("(key) name", capitalize(props.name))}!`,
|
||||
`Hello, ${fbt.param("(key) name", identity(props.name))}!`,
|
||||
"(description) Greeting"
|
||||
);
|
||||
return <div>{text}</div>;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{ name: "Sathya" }],
|
||||
};
|
||||
|
||||
+10
@@ -12,6 +12,11 @@ function Component(props) {
|
||||
return <div>{text}</div>;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{ count: 2 }],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
@@ -46,5 +51,10 @@ function Component(props) {
|
||||
return t1;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{ count: 2 }],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
+5
@@ -7,3 +7,8 @@ function Component(props) {
|
||||
);
|
||||
return <div>{text}</div>;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{ count: 2 }],
|
||||
};
|
||||
|
||||
+15
-3
@@ -3,6 +3,7 @@
|
||||
|
||||
```javascript
|
||||
import fbt from "fbt";
|
||||
import { Stringify } from "shared-runtime";
|
||||
|
||||
export function Component(props) {
|
||||
let count = 0;
|
||||
@@ -10,16 +11,21 @@ export function Component(props) {
|
||||
count = props.items.length;
|
||||
}
|
||||
return (
|
||||
<View>
|
||||
<Stringify>
|
||||
{fbt(
|
||||
`for ${fbt.param("count", count)} experiences`,
|
||||
`Label for the number of items`,
|
||||
{ project: "public" }
|
||||
)}
|
||||
</View>
|
||||
</Stringify>
|
||||
);
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{ items: [1, 2, 3] }],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
@@ -27,6 +33,7 @@ export function Component(props) {
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
import fbt from "fbt";
|
||||
import { Stringify } from "shared-runtime";
|
||||
|
||||
export function Component(props) {
|
||||
const $ = useMemoCache(4);
|
||||
@@ -46,7 +53,7 @@ export function Component(props) {
|
||||
}
|
||||
let t1;
|
||||
if ($[2] !== t0) {
|
||||
t1 = <View>{t0}</View>;
|
||||
t1 = <Stringify>{t0}</Stringify>;
|
||||
$[2] = t0;
|
||||
$[3] = t1;
|
||||
} else {
|
||||
@@ -55,5 +62,10 @@ export function Component(props) {
|
||||
return t1;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{ items: [1, 2, 3] }],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
+8
-2
@@ -1,4 +1,5 @@
|
||||
import fbt from "fbt";
|
||||
import { Stringify } from "shared-runtime";
|
||||
|
||||
export function Component(props) {
|
||||
let count = 0;
|
||||
@@ -6,12 +7,17 @@ export function Component(props) {
|
||||
count = props.items.length;
|
||||
}
|
||||
return (
|
||||
<View>
|
||||
<Stringify>
|
||||
{fbt(
|
||||
`for ${fbt.param("count", count)} experiences`,
|
||||
`Label for the number of items`,
|
||||
{ project: "public" }
|
||||
)}
|
||||
</View>
|
||||
</Stringify>
|
||||
);
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{ items: [1, 2, 3] }],
|
||||
};
|
||||
|
||||
@@ -415,9 +415,6 @@ const skipFilter = new Set([
|
||||
"multi-arrow-expr-export-default-gating-test",
|
||||
|
||||
// TODO: we should be able to support these
|
||||
"fbt-call",
|
||||
"fbt-call-complex-param-value",
|
||||
"fbt-template-string-same-scope",
|
||||
"component-declaration-basic.flow",
|
||||
"nested-function-with-param-as-captured-dep",
|
||||
"readonly-object-method-calls",
|
||||
|
||||
Reference in New Issue
Block a user