@samitouri / QOS-React-1 / commits / 59ddf537ed

[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> ... ```

Mofei Zhang committed Nov 9, 2023 at 18:55 UTC 59ddf537ed2b4672ce3ca3f330c360d05e5c9e9e
7 files changed +59 -11
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt-call-complex-param-value.expect.md
+14 -2
@@ -3,15 +3,21 @@
3
4 ```javascript
5 import fbt from "fbt";
6 +import { identity } from "shared-runtime";
7
8 function Component(props) {
9 const text = fbt(
9 - `Hello, ${fbt.param("(key) name", capitalize(props.name))}!`,
10 + `Hello, ${fbt.param("(key) name", identity(props.name))}!`,
11 "(description) Greeting"
12 );
13 return <div>{text}</div>;
14 }
15
16 +export const FIXTURE_ENTRYPOINT = {
17 + fn: Component,
18 + params: [{ name: "Sathya" }],
19 +};
20 +
21 ```
22
23 ## Code
@@ -19,6 +25,7 @@ function Component(props) {
25 ```javascript
26 import { unstable_useMemoCache as useMemoCache } from "react";
27 import fbt from "fbt";
28 +import { identity } from "shared-runtime";
29
30 function Component(props) {
31 const $ = useMemoCache(4);
@@ -26,7 +33,7 @@ function Component(props) {
33 if ($[0] !== props.name) {
34 t0 = fbt._(
35 "Hello, {(key) name}!",
29 - [fbt._param("(key) name", capitalize(props.name))],
36 + [fbt._param("(key) name", identity(props.name))],
37 { hk: "2sOsn5" }
38 );
39 $[0] = props.name;
@@ -46,5 +53,10 @@ function Component(props) {
53 return t1;
54 }
55
56 +export const FIXTURE_ENTRYPOINT = {
57 + fn: Component,
58 + params: [{ name: "Sathya" }],
59 +};
60 +
61 ```
62
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt-call-complex-param-value.js
+7 -1
@@ -1,9 +1,15 @@
1 import fbt from "fbt";
2 +import { identity } from "shared-runtime";
3
4 function Component(props) {
5 const text = fbt(
5 - `Hello, ${fbt.param("(key) name", capitalize(props.name))}!`,
6 + `Hello, ${fbt.param("(key) name", identity(props.name))}!`,
7 "(description) Greeting"
8 );
9 return <div>{text}</div>;
10 }
11 +
12 +export const FIXTURE_ENTRYPOINT = {
13 + fn: Component,
14 + params: [{ name: "Sathya" }],
15 +};
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt-call.expect.md
+10
@@ -12,6 +12,11 @@ function Component(props) {
12 return <div>{text}</div>;
13 }
14
15 +export const FIXTURE_ENTRYPOINT = {
16 + fn: Component,
17 + params: [{ count: 2 }],
18 +};
19 +
20 ```
21
22 ## Code
@@ -46,5 +51,10 @@ function Component(props) {
51 return t1;
52 }
53
54 +export const FIXTURE_ENTRYPOINT = {
55 + fn: Component,
56 + params: [{ count: 2 }],
57 +};
58 +
59 ```
60
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt-call.js
+5
@@ -7,3 +7,8 @@ function Component(props) {
7 );
8 return <div>{text}</div>;
9 }
10 +
11 +export const FIXTURE_ENTRYPOINT = {
12 + fn: Component,
13 + params: [{ count: 2 }],
14 +};
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt-template-string-same-scope.expect.md
+15 -3
@@ -3,6 +3,7 @@
3
4 ```javascript
5 import fbt from "fbt";
6 +import { Stringify } from "shared-runtime";
7
8 export function Component(props) {
9 let count = 0;
@@ -10,16 +11,21 @@ export function Component(props) {
11 count = props.items.length;
12 }
13 return (
13 - <View>
14 + <Stringify>
15 {fbt(
16 `for ${fbt.param("count", count)} experiences`,
17 `Label for the number of items`,
18 { project: "public" }
19 )}
19 - </View>
20 + </Stringify>
21 );
22 }
23
24 +export const FIXTURE_ENTRYPOINT = {
25 + fn: Component,
26 + params: [{ items: [1, 2, 3] }],
27 +};
28 +
29 ```
30
31 ## Code
@@ -27,6 +33,7 @@ export function Component(props) {
33 ```javascript
34 import { unstable_useMemoCache as useMemoCache } from "react";
35 import fbt from "fbt";
36 +import { Stringify } from "shared-runtime";
37
38 export function Component(props) {
39 const $ = useMemoCache(4);
@@ -46,7 +53,7 @@ export function Component(props) {
53 }
54 let t1;
55 if ($[2] !== t0) {
49 - t1 = <View>{t0}</View>;
56 + t1 = <Stringify>{t0}</Stringify>;
57 $[2] = t0;
58 $[3] = t1;
59 } else {
@@ -55,5 +62,10 @@ export function Component(props) {
62 return t1;
63 }
64
65 +export const FIXTURE_ENTRYPOINT = {
66 + fn: Component,
67 + params: [{ items: [1, 2, 3] }],
68 +};
69 +
70 ```
71
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/fbt-template-string-same-scope.js
+8 -2
@@ -1,4 +1,5 @@
1 import fbt from "fbt";
2 +import { Stringify } from "shared-runtime";
3
4 export function Component(props) {
5 let count = 0;
@@ -6,12 +7,17 @@ export function Component(props) {
7 count = props.items.length;
8 }
9 return (
9 - <View>
10 + <Stringify>
11 {fbt(
12 `for ${fbt.param("count", count)} experiences`,
13 `Label for the number of items`,
14 { project: "public" }
15 )}
15 - </View>
16 + </Stringify>
17 );
18 }
19 +
20 +export const FIXTURE_ENTRYPOINT = {
21 + fn: Component,
22 + params: [{ items: [1, 2, 3] }],
23 +};
compiler/packages/sprout/src/SproutTodoFilter.ts
-3
@@ -415,9 +415,6 @@ const skipFilter = new Set([
415 "multi-arrow-expr-export-default-gating-test",
416
417 // TODO: we should be able to support these
418 - "fbt-call",
419 - "fbt-call-complex-param-value",
420 - "fbt-template-string-same-scope",
418 "component-declaration-basic.flow",
419 "nested-function-with-param-as-captured-dep",
420 "readonly-object-method-calls",