diff --git a/packages/babel-plugin-fbtee/src/__tests__/FbtTestUtil.tsx b/packages/babel-plugin-fbtee/src/__tests__/FbtTestUtil.tsx index 67488685..aa2b67ac 100644 --- a/packages/babel-plugin-fbtee/src/__tests__/FbtTestUtil.tsx +++ b/packages/babel-plugin-fbtee/src/__tests__/FbtTestUtil.tsx @@ -1,4 +1,4 @@ -import babel, { PluginItem, PluginOptions, transformSync } from '@babel/core'; +import { PluginOptions, transformSync } from '@babel/core'; import generate from '@babel/generator'; import { parse as babelParse } from '@babel/parser'; import syntaxJSX from '@babel/plugin-syntax-jsx'; @@ -7,7 +7,6 @@ import presetTypeScript from '@babel/preset-typescript'; import { Node } from '@babel/types'; import { expect } from '@jest/globals'; import prettier from 'prettier-2'; -import { SENTINEL } from '../FbtConstants.tsx'; import fbt from '../index.tsx'; export function payload(obj: Record): string { @@ -32,7 +31,7 @@ export function snapshotTransform( source: string, pluginOptions?: PluginOptions, ): string { - return transform(source, { fbtBase64: true, ...pluginOptions }); + return prettier.format(transform(source, pluginOptions), { parser: 'babel' }); } async function transformKeepJsx( @@ -54,8 +53,7 @@ async function transformKeepJsx( export const snapshotTransformKeepJsx = ( source: string, pluginOptions?: PluginOptions, -): Promise => - transformKeepJsx(source, { fbtBase64: true, ...pluginOptions }); +): Promise => transformKeepJsx(source, pluginOptions); export function withFbsImportStatement(code: string): string { return `import { fbs } from "fbtee"; @@ -75,14 +73,7 @@ export function withFbtImportStatement(code: string): string { */ export const jsCodeFbtCallSerializer = { serialize(rawValue: string) { - const decoded = rawValue.replaceAll( - /(["'])__FBT__(.*?)__FBT__\1/gm, - (_match, _quote, body) => { - const json = Buffer.from(body, 'base64').toString('utf8'); - return `/* ${SENTINEL} start */ ${json} /* ${SENTINEL} end */`; - }, - ); - return prettier.format(decoded, { parser: 'babel' }); + return prettier.format(rawValue, { parser: 'babel' }); }, test(rawValue: unknown): rawValue is string { @@ -338,21 +329,3 @@ export function testSection( }); }); } - -export function testCase( - name: string, - plugins: Array, - testData: TestCases, - options: Options, -) { - describe(name, () => - testSection( - testData, - (source: string) => - babel.transformSync(source, { - plugins, - })?.code || '', - options, - ), - ); -} diff --git a/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbs-test.tsx.snap b/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbs-test.tsx.snap index 7b9f9d15..2d8245a6 100644 --- a/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbs-test.tsx.snap +++ b/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbs-test.tsx.snap @@ -2,37 +2,28 @@ exports[`Test declarative (jsx) syntax translation should convert a common string 1`] = ` import { fbs } from "fbtee"; -const fbsCommonElem = fbs._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "Button to post a comment", text: "Post" } }, - project: "", - } /* __FBT__ end */ -); +const fbsCommonElem = fbs._("Post", null, { + hk: "2y9OIZ", +}); `; exports[`Test declarative (jsx) syntax translation should convert a simple string 1`] = ` import { fbs } from "fbtee"; -const fbsElem = fbs._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "str_description", text: "a simple string" } }, - project: "", - } /* __FBT__ end */ -); +const fbsElem = fbs._("a simple string", null, { + hk: "1jd7FI", +}); `; exports[`Test declarative (jsx) syntax translation should convert a string with a parameter 1`] = ` import { fbs } from "fbtee"; const fbsElem = fbs._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { desc: "str_description", text: "a string with a {param name}" }, - }, - project: "", - } /* __FBT__ end */, - [fbs._param("param name", parameter)] + "a string with a {param name}", + [fbs._param("param name", parameter)], + { + hk: "46D2WH", + } ); `; @@ -41,41 +32,32 @@ exports[`Test declarative (jsx) syntax translation should handle 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "d", text: "{param} test" } }, - project: "", - } /* __FBT__ end */, + "{param} test", [ fbt._param( "param", @@ -103,15 +86,15 @@ fbt._( React.Fragment, null, /*#__PURE__*/ React.createElement("b", null, "Test"), - fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "test", text: "simple" } }, - project: "", - } /* __FBT__ end */ - ) + fbt._("simple", null, { + hk: "2pjKFw", + }) ) ), - ] + ], + { + hk: "154Qct", + } ); `; diff --git a/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbtAutoWrap-test.tsx.snap b/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbtAutoWrap-test.tsx.snap index 6470bf59..f0962a1d 100644 --- a/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbtAutoWrap-test.tsx.snap +++ b/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbtAutoWrap-test.tsx.snap @@ -6,29 +6,12 @@ import { fbt } from "fbtee"; (fbt_sv_arg_0 = fbt._name("bar", bar, g)), (fbt_sv_arg_1 = fbt._plural(num, "baz")), fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [ - { token: "bar", type: 1 }, - { singular: true, token: "baz", type: 2 }, - ], - t: { - "*": { - "*": { - desc: "some-desc", - text: "Level 1 {foo}{=Level 2 [bar]Level 3 [baz] cats}", - tokenAliases: { "=Level 2 [bar]Level 3 [baz] cats": "=m2" }, - }, - _1: { - desc: "some-desc", - text: "Level 1 {foo}{=Level 2 [bar]Level 3 1 cat}", - tokenAliases: { "=Level 2 [bar]Level 3 1 cat": "=m2" }, - }, - }, - }, + { + "*": { + "*": "Level 1 {foo}{=m2}", + _1: "Level 1 {foo}{=m2}", }, - project: "", - } /* __FBT__ end */, + }, [ fbt_sv_arg_0, fbt_sv_arg_1, @@ -39,29 +22,12 @@ import { fbt } from "fbtee"; "a", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [ - { token: "bar", type: 1 }, - { singular: true, token: "baz", type: 2 }, - ], - t: { - "*": { - "*": { - desc: 'In the phrase: "Level 1 {foo}{=Level 2 [bar]Level 3 [baz] cats}"', - text: "Level 2 {bar}{=Level 3 [baz] cats}", - tokenAliases: { "=Level 3 [baz] cats": "=m2" }, - }, - _1: { - desc: 'In the phrase: "Level 1 {foo}{=Level 2 [bar]Level 3 1 cat}"', - text: "Level 2 {bar}{=Level 3 1 cat}", - tokenAliases: { "=Level 3 1 cat": "=m2" }, - }, - }, - }, + { + "*": { + "*": "Level 2 {bar}{=m2}", + _1: "Level 2 {bar}{=m2}", }, - project: "", - } /* __FBT__ end */, + }, [ fbt_sv_arg_0, fbt_sv_arg_1, @@ -71,36 +37,30 @@ import { fbt } from "fbtee"; "b", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [ - { token: "bar", type: 1 }, - { singular: true, token: "baz", type: 2 }, - ], - t: { - "*": { - "*": { - desc: 'In the phrase: "Level 1 {foo}Level 2 {bar}{=Level 3 [baz] cats}"', - text: "Level 3 {baz} cats", - }, - _1: { - desc: 'In the phrase: "Level 1 {foo}Level 2 {bar}{=Level 3 1 cat}"', - text: "Level 3 1 cat", - }, - }, - }, + { + "*": { + "*": "Level 3 {baz} cats", + _1: "Level 3 1 cat", }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0, fbt_sv_arg_1] + }, + [fbt_sv_arg_0, fbt_sv_arg_1], + { + hk: "3hoLPG", + } ) ) ), - ] + ], + { + hk: "1TQlfE", + } ) ) ), - ] + ], + { + hk: "2Aoh3a", + } ); `; @@ -112,74 +72,22 @@ import { fbt } from "fbtee"; (fbt_sv_arg_1 = fbt._pronoun(1, g1)), (fbt_sv_arg_2 = fbt._plural(num, "foo")), fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [ - { token: "__subject__", type: 1 }, - null, - { singular: true, token: "foo", type: 2 }, - ], - t: { - "*": { - 1: { - "*": { - desc: "description", - text: "Level 1 {=her some_pronoun}{=Level 2 [foo] cats}", - tokenAliases: { - "=her some_pronoun": "=m1", - "=Level 2 [foo] cats": "=m2", - }, - }, - _1: { - desc: "description", - text: "Level 1 {=her some_pronoun}{=Level 2 1 cat}", - tokenAliases: { - "=her some_pronoun": "=m1", - "=Level 2 1 cat": "=m2", - }, - }, - }, - 2: { - "*": { - desc: "description", - text: "Level 1 {=his some_pronoun}{=Level 2 [foo] cats}", - tokenAliases: { - "=his some_pronoun": "=m1", - "=Level 2 [foo] cats": "=m2", - }, - }, - _1: { - desc: "description", - text: "Level 1 {=his some_pronoun}{=Level 2 1 cat}", - tokenAliases: { - "=his some_pronoun": "=m1", - "=Level 2 1 cat": "=m2", - }, - }, - }, - "*": { - "*": { - desc: "description", - text: "Level 1 {=their some_pronoun}{=Level 2 [foo] cats}", - tokenAliases: { - "=their some_pronoun": "=m1", - "=Level 2 [foo] cats": "=m2", - }, - }, - _1: { - desc: "description", - text: "Level 1 {=their some_pronoun}{=Level 2 1 cat}", - tokenAliases: { - "=their some_pronoun": "=m1", - "=Level 2 1 cat": "=m2", - }, - }, - }, - }, + { + "*": { + 1: { + "*": "Level 1 {=m1}{=m2}", + _1: "Level 1 {=m1}{=m2}", + }, + 2: { + "*": "Level 1 {=m1}{=m2}", + _1: "Level 1 {=m1}{=m2}", + }, + "*": { + "*": "Level 1 {=m1}{=m2}", + _1: "Level 1 {=m1}{=m2}", }, }, - project: "", - } /* __FBT__ end */, + }, [ fbt_sv_arg_0, fbt_sv_arg_1, @@ -192,51 +100,26 @@ import { fbt } from "fbtee"; href: "#new", }, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [ - { token: "__subject__", type: 1 }, - null, - { singular: true, token: "foo", type: 2 }, - ], - t: { - "*": { - 1: { - "*": { - desc: 'In the phrase: "Level 1 {=her some_pronoun}{=Level 2 [foo] cats}"', - text: "her some_pronoun", - }, - _1: { - desc: 'In the phrase: "Level 1 {=her some_pronoun}{=Level 2 1 cat}"', - text: "her some_pronoun", - }, - }, - 2: { - "*": { - desc: 'In the phrase: "Level 1 {=his some_pronoun}{=Level 2 [foo] cats}"', - text: "his some_pronoun", - }, - _1: { - desc: 'In the phrase: "Level 1 {=his some_pronoun}{=Level 2 1 cat}"', - text: "his some_pronoun", - }, - }, - "*": { - "*": { - desc: 'In the phrase: "Level 1 {=their some_pronoun}{=Level 2 [foo] cats}"', - text: "their some_pronoun", - }, - _1: { - desc: 'In the phrase: "Level 1 {=their some_pronoun}{=Level 2 1 cat}"', - text: "their some_pronoun", - }, - }, - }, + { + "*": { + 1: { + "*": "her some_pronoun", + _1: "her some_pronoun", + }, + 2: { + "*": "his some_pronoun", + _1: "his some_pronoun", + }, + "*": { + "*": "their some_pronoun", + _1: "their some_pronoun", }, }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0, fbt_sv_arg_1, fbt_sv_arg_2] + }, + [fbt_sv_arg_0, fbt_sv_arg_1, fbt_sv_arg_2], + { + hk: "4sbfj7", + } ) ) ), @@ -246,55 +129,33 @@ import { fbt } from "fbtee"; "b", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [ - { token: "__subject__", type: 1 }, - null, - { singular: true, token: "foo", type: 2 }, - ], - t: { - "*": { - 1: { - "*": { - desc: 'In the phrase: "Level 1 {=her some_pronoun}{=Level 2 [foo] cats}"', - text: "Level 2 {foo} cats", - }, - _1: { - desc: 'In the phrase: "Level 1 {=her some_pronoun}{=Level 2 1 cat}"', - text: "Level 2 1 cat", - }, - }, - 2: { - "*": { - desc: 'In the phrase: "Level 1 {=his some_pronoun}{=Level 2 [foo] cats}"', - text: "Level 2 {foo} cats", - }, - _1: { - desc: 'In the phrase: "Level 1 {=his some_pronoun}{=Level 2 1 cat}"', - text: "Level 2 1 cat", - }, - }, - "*": { - "*": { - desc: 'In the phrase: "Level 1 {=their some_pronoun}{=Level 2 [foo] cats}"', - text: "Level 2 {foo} cats", - }, - _1: { - desc: 'In the phrase: "Level 1 {=their some_pronoun}{=Level 2 1 cat}"', - text: "Level 2 1 cat", - }, - }, - }, + { + "*": { + 1: { + "*": "Level 2 {foo} cats", + _1: "Level 2 1 cat", + }, + 2: { + "*": "Level 2 {foo} cats", + _1: "Level 2 1 cat", + }, + "*": { + "*": "Level 2 {foo} cats", + _1: "Level 2 1 cat", }, }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0, fbt_sv_arg_1, fbt_sv_arg_2] + }, + [fbt_sv_arg_0, fbt_sv_arg_1, fbt_sv_arg_2], + { + hk: "2Eow7W", + } ) ) ), - ] + ], + { + hk: "3S7xV4", + } ); `; @@ -306,94 +167,25 @@ import { fbt } from "fbtee"; (fbt_sv_arg_1 = fbt._pronoun(1, g1)), (fbt_sv_arg_2 = fbt._pronoun(1, g2)), fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [{ token: "__subject__", type: 1 }, null, null], - t: { - "*": { - 1: { - 1: { - desc: "description", - text: "Level 1 {=her some_pronoun}{=Level 2 her some_pronoun}", - tokenAliases: { - "=her some_pronoun": "=m1", - "=Level 2 her some_pronoun": "=m2", - }, - }, - 2: { - desc: "description", - text: "Level 1 {=her some_pronoun}{=Level 2 his some_pronoun}", - tokenAliases: { - "=her some_pronoun": "=m1", - "=Level 2 his some_pronoun": "=m2", - }, - }, - "*": { - desc: "description", - text: "Level 1 {=her some_pronoun}{=Level 2 their some_pronoun}", - tokenAliases: { - "=her some_pronoun": "=m1", - "=Level 2 their some_pronoun": "=m2", - }, - }, - }, - 2: { - 1: { - desc: "description", - text: "Level 1 {=his some_pronoun}{=Level 2 her some_pronoun}", - tokenAliases: { - "=his some_pronoun": "=m1", - "=Level 2 her some_pronoun": "=m2", - }, - }, - 2: { - desc: "description", - text: "Level 1 {=his some_pronoun}{=Level 2 his some_pronoun}", - tokenAliases: { - "=his some_pronoun": "=m1", - "=Level 2 his some_pronoun": "=m2", - }, - }, - "*": { - desc: "description", - text: "Level 1 {=his some_pronoun}{=Level 2 their some_pronoun}", - tokenAliases: { - "=his some_pronoun": "=m1", - "=Level 2 their some_pronoun": "=m2", - }, - }, - }, - "*": { - 1: { - desc: "description", - text: "Level 1 {=their some_pronoun}{=Level 2 her some_pronoun}", - tokenAliases: { - "=their some_pronoun": "=m1", - "=Level 2 her some_pronoun": "=m2", - }, - }, - 2: { - desc: "description", - text: "Level 1 {=their some_pronoun}{=Level 2 his some_pronoun}", - tokenAliases: { - "=their some_pronoun": "=m1", - "=Level 2 his some_pronoun": "=m2", - }, - }, - "*": { - desc: "description", - text: "Level 1 {=their some_pronoun}{=Level 2 their some_pronoun}", - tokenAliases: { - "=their some_pronoun": "=m1", - "=Level 2 their some_pronoun": "=m2", - }, - }, - }, - }, + { + "*": { + 1: { + 1: "Level 1 {=m1}{=m2}", + 2: "Level 1 {=m1}{=m2}", + "*": "Level 1 {=m1}{=m2}", + }, + 2: { + 1: "Level 1 {=m1}{=m2}", + 2: "Level 1 {=m1}{=m2}", + "*": "Level 1 {=m1}{=m2}", + }, + "*": { + 1: "Level 1 {=m1}{=m2}", + 2: "Level 1 {=m1}{=m2}", + "*": "Level 1 {=m1}{=m2}", }, }, - project: "", - } /* __FBT__ end */, + }, [ fbt_sv_arg_0, fbt_sv_arg_1, @@ -406,59 +198,29 @@ import { fbt } from "fbtee"; href: "#new", }, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [{ token: "__subject__", type: 1 }, null, null], - t: { - "*": { - 1: { - 1: { - desc: 'In the phrase: "Level 1 {=her some_pronoun}{=Level 2 her some_pronoun}"', - text: "her some_pronoun", - }, - 2: { - desc: 'In the phrase: "Level 1 {=her some_pronoun}{=Level 2 his some_pronoun}"', - text: "her some_pronoun", - }, - "*": { - desc: 'In the phrase: "Level 1 {=her some_pronoun}{=Level 2 their some_pronoun}"', - text: "her some_pronoun", - }, - }, - 2: { - 1: { - desc: 'In the phrase: "Level 1 {=his some_pronoun}{=Level 2 her some_pronoun}"', - text: "his some_pronoun", - }, - 2: { - desc: 'In the phrase: "Level 1 {=his some_pronoun}{=Level 2 his some_pronoun}"', - text: "his some_pronoun", - }, - "*": { - desc: 'In the phrase: "Level 1 {=his some_pronoun}{=Level 2 their some_pronoun}"', - text: "his some_pronoun", - }, - }, - "*": { - 1: { - desc: 'In the phrase: "Level 1 {=their some_pronoun}{=Level 2 her some_pronoun}"', - text: "their some_pronoun", - }, - 2: { - desc: 'In the phrase: "Level 1 {=their some_pronoun}{=Level 2 his some_pronoun}"', - text: "their some_pronoun", - }, - "*": { - desc: 'In the phrase: "Level 1 {=their some_pronoun}{=Level 2 their some_pronoun}"', - text: "their some_pronoun", - }, - }, - }, + { + "*": { + 1: { + 1: "her some_pronoun", + 2: "her some_pronoun", + "*": "her some_pronoun", + }, + 2: { + 1: "his some_pronoun", + 2: "his some_pronoun", + "*": "his some_pronoun", + }, + "*": { + 1: "their some_pronoun", + 2: "their some_pronoun", + "*": "their some_pronoun", }, }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0, fbt_sv_arg_1, fbt_sv_arg_2] + }, + [fbt_sv_arg_0, fbt_sv_arg_1, fbt_sv_arg_2], + { + hk: "3VitZN", + } ) ) ), @@ -468,67 +230,25 @@ import { fbt } from "fbtee"; "b", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [{ token: "__subject__", type: 1 }, null, null], - t: { - "*": { - 1: { - 1: { - desc: 'In the phrase: "Level 1 {=her some_pronoun}{=Level 2 her some_pronoun}"', - text: "Level 2 {=her some_pronoun}", - tokenAliases: { "=her some_pronoun": "=m1" }, - }, - 2: { - desc: 'In the phrase: "Level 1 {=her some_pronoun}{=Level 2 his some_pronoun}"', - text: "Level 2 {=his some_pronoun}", - tokenAliases: { "=his some_pronoun": "=m1" }, - }, - "*": { - desc: 'In the phrase: "Level 1 {=her some_pronoun}{=Level 2 their some_pronoun}"', - text: "Level 2 {=their some_pronoun}", - tokenAliases: { "=their some_pronoun": "=m1" }, - }, - }, - 2: { - 1: { - desc: 'In the phrase: "Level 1 {=his some_pronoun}{=Level 2 her some_pronoun}"', - text: "Level 2 {=her some_pronoun}", - tokenAliases: { "=her some_pronoun": "=m1" }, - }, - 2: { - desc: 'In the phrase: "Level 1 {=his some_pronoun}{=Level 2 his some_pronoun}"', - text: "Level 2 {=his some_pronoun}", - tokenAliases: { "=his some_pronoun": "=m1" }, - }, - "*": { - desc: 'In the phrase: "Level 1 {=his some_pronoun}{=Level 2 their some_pronoun}"', - text: "Level 2 {=their some_pronoun}", - tokenAliases: { "=their some_pronoun": "=m1" }, - }, - }, - "*": { - 1: { - desc: 'In the phrase: "Level 1 {=their some_pronoun}{=Level 2 her some_pronoun}"', - text: "Level 2 {=her some_pronoun}", - tokenAliases: { "=her some_pronoun": "=m1" }, - }, - 2: { - desc: 'In the phrase: "Level 1 {=their some_pronoun}{=Level 2 his some_pronoun}"', - text: "Level 2 {=his some_pronoun}", - tokenAliases: { "=his some_pronoun": "=m1" }, - }, - "*": { - desc: 'In the phrase: "Level 1 {=their some_pronoun}{=Level 2 their some_pronoun}"', - text: "Level 2 {=their some_pronoun}", - tokenAliases: { "=their some_pronoun": "=m1" }, - }, - }, - }, + { + "*": { + 1: { + 1: "Level 2 {=m1}", + 2: "Level 2 {=m1}", + "*": "Level 2 {=m1}", + }, + 2: { + 1: "Level 2 {=m1}", + 2: "Level 2 {=m1}", + "*": "Level 2 {=m1}", + }, + "*": { + 1: "Level 2 {=m1}", + 2: "Level 2 {=m1}", + "*": "Level 2 {=m1}", }, }, - project: "", - } /* __FBT__ end */, + }, [ fbt_sv_arg_0, fbt_sv_arg_1, @@ -541,67 +261,43 @@ import { fbt } from "fbtee"; href: "#new", }, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [{ token: "__subject__", type: 1 }, null, null], - t: { - "*": { - 1: { - 1: { - desc: 'In the phrase: "Level 1 {=her some_pronoun}Level 2 {=her some_pronoun}"', - text: "her some_pronoun", - }, - 2: { - desc: 'In the phrase: "Level 1 {=her some_pronoun}Level 2 {=his some_pronoun}"', - text: "his some_pronoun", - }, - "*": { - desc: 'In the phrase: "Level 1 {=her some_pronoun}Level 2 {=their some_pronoun}"', - text: "their some_pronoun", - }, - }, - 2: { - 1: { - desc: 'In the phrase: "Level 1 {=his some_pronoun}Level 2 {=her some_pronoun}"', - text: "her some_pronoun", - }, - 2: { - desc: 'In the phrase: "Level 1 {=his some_pronoun}Level 2 {=his some_pronoun}"', - text: "his some_pronoun", - }, - "*": { - desc: 'In the phrase: "Level 1 {=his some_pronoun}Level 2 {=their some_pronoun}"', - text: "their some_pronoun", - }, - }, - "*": { - 1: { - desc: 'In the phrase: "Level 1 {=their some_pronoun}Level 2 {=her some_pronoun}"', - text: "her some_pronoun", - }, - 2: { - desc: 'In the phrase: "Level 1 {=their some_pronoun}Level 2 {=his some_pronoun}"', - text: "his some_pronoun", - }, - "*": { - desc: 'In the phrase: "Level 1 {=their some_pronoun}Level 2 {=their some_pronoun}"', - text: "their some_pronoun", - }, - }, - }, + { + "*": { + 1: { + 1: "her some_pronoun", + 2: "his some_pronoun", + "*": "their some_pronoun", + }, + 2: { + 1: "her some_pronoun", + 2: "his some_pronoun", + "*": "their some_pronoun", + }, + "*": { + 1: "her some_pronoun", + 2: "his some_pronoun", + "*": "their some_pronoun", }, }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0, fbt_sv_arg_1, fbt_sv_arg_2] + }, + [fbt_sv_arg_0, fbt_sv_arg_1, fbt_sv_arg_2], + { + hk: "3LBN3N", + } ) ) ), - ] + ], + { + hk: "2SjiyB", + } ) ) ), - ] + ], + { + hk: "4anRqJ", + } ); `; @@ -609,17 +305,7 @@ import { fbt } from "fbtee"; exports[`Test jsx auto-wrapping of implicit parameters should auto wrap a simple test with a nested level 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d", - text: "{=Your friends liked} your video", - tokenAliases: { "=Your friends liked": "=m0" }, - }, - }, - project: "", - } /* __FBT__ end */, + "{=m0} your video", [ fbt._implicitParam( "=m0", @@ -629,42 +315,29 @@ fbt._( href: "#", }, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=Your friends liked} your video"', - text: "Your friends {=liked}", - tokenAliases: { "=liked": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "Your friends {=m1}", [ fbt._implicitParam( "=m1", /*#__PURE__*/ React.createElement( "b", null, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "Your friends {=liked} your video"', - text: "liked", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("liked", null, { + hk: "6REFx", + }) ) ), - ] + ], + { + hk: "1h9ToV", + } ) ) ), - ] + ], + { + hk: "1C8Sp8", + } ); `; @@ -672,17 +345,7 @@ fbt._( exports[`Test jsx auto-wrapping of implicit parameters should auto wrap a simple test with one level 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d", - text: "{=Your friends} liked your video", - tokenAliases: { "=Your friends": "=m0" }, - }, - }, - project: "", - } /* __FBT__ end */, + "{=m0} liked your video", [ fbt._implicitParam( "=m0", @@ -691,21 +354,15 @@ fbt._( { href: "#", }, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=Your friends} liked your video"', - text: "Your friends", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("Your friends", null, { + hk: "EXsAo", + }) ) ), - ] + ], + { + hk: "JEQEn", + } ); `; @@ -716,17 +373,7 @@ import { fbt } from "fbtee"; "div", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "one", - text: "{=first} fbt call", - tokenAliases: { "=first": "=m0" }, - }, - }, - project: "", - } /* __FBT__ end */, + "{=m0} fbt call", [ fbt._implicitParam( "=m0", @@ -735,34 +382,18 @@ import { fbt } from "fbtee"; { href: "#", }, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=first} fbt call"', - text: "first", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("first", null, { + hk: "20XRQM", + }) ) ), - ] + ], + { + hk: "2oLntp", + } ), fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "two", - text: "{=second} test", - tokenAliases: { "=second": "=m0" }, - }, - }, - project: "", - } /* __FBT__ end */, + "{=m0} test", [ fbt._implicitParam( "=m0", @@ -771,18 +402,15 @@ import { fbt } from "fbtee"; { href: "#", }, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { desc: 'In the phrase: "{=second} test"', text: "second" }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("second", null, { + hk: "2kqUOm", + }) ) ), - ] + ], + { + hk: "2f9gKU", + } ) ); @@ -791,10 +419,7 @@ import { fbt } from "fbtee"; exports[`Test jsx auto-wrapping of implicit parameters should wrap a child nested in an explicit 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "d", text: "{explicit fbt param}" } }, - project: "", - } /* __FBT__ end */, + "{explicit fbt param}", [ fbt._param( "explicit fbt param", @@ -802,42 +427,29 @@ fbt._( "div", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d2", - text: "explicit fbt param {=with a nested implicit param}", - tokenAliases: { "=with a nested implicit param": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "explicit fbt param {=m1}", [ fbt._implicitParam( "=m1", /*#__PURE__*/ React.createElement( "div", null, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "explicit fbt param {=with a nested implicit param}"', - text: "with a nested implicit param", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("with a nested implicit param", null, { + hk: "47XKzg", + }) ) ), - ] + ], + { + hk: "4aGXvg", + } ) ) ), - ] + ], + { + hk: "1t6SVf", + } ); `; @@ -845,29 +457,16 @@ fbt._( exports[`Test jsx auto-wrapping of implicit parameters should wrap a child next to an explicit 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d", - text: "{explicit param next to}{=an implicit param}", - tokenAliases: { "=an implicit param": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "{explicit param next to}{=m1}", [ fbt._param( "explicit param next to", /*#__PURE__*/ React.createElement( "div", null, - fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "d2", text: "explicit param next to" } }, - project: "", - } /* __FBT__ end */ - ) + fbt._("explicit param next to", null, { + hk: "4BQGPe", + }) ) ), fbt._implicitParam( @@ -875,21 +474,15 @@ fbt._( /*#__PURE__*/ React.createElement( "div", null, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{explicit param next to}{=an implicit param}"', - text: "an implicit param", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("an implicit param", null, { + hk: "140tMj", + }) ) ), - ] + ], + { + hk: "voXwD", + } ); `; @@ -897,17 +490,7 @@ fbt._( exports[`Test jsx auto-wrapping of implicit parameters should wrap a single unwrapped child and a string above 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d", - text: "{=This is a nested} test", - tokenAliases: { "=This is a nested": "=m0" }, - }, - }, - project: "", - } /* __FBT__ end */, + "{=m0} test", [ fbt._implicitParam( "=m0", @@ -915,17 +498,7 @@ fbt._( "b", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=This is a nested} test"', - text: "This is {=a nested}", - tokenAliases: { "=a nested": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "This is {=m1}", [ fbt._implicitParam( "=m1", @@ -934,25 +507,22 @@ fbt._( { href: "#", }, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "This is {=a nested} test"', - text: "a nested", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("a nested", null, { + hk: "2neJtx", + }) ) ), - ] + ], + { + hk: "2sVZgG", + } ) ) ), - ] + ], + { + hk: "18fFtb", + } ); `; @@ -960,17 +530,7 @@ fbt._( exports[`Test jsx auto-wrapping of implicit parameters should wrap a single unwrapped child and a string below 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d", - text: "{=this is} a singly nested test", - tokenAliases: { "=this is": "=m0" }, - }, - }, - project: "", - } /* __FBT__ end */, + "{=m0} a singly nested test", [ fbt._implicitParam( "=m0", @@ -979,21 +539,15 @@ fbt._( { href: "#", }, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=this is} a singly nested test"', - text: "this is", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("this is", null, { + hk: "1p5dUU", + }) ) ), - ] + ], + { + hk: "1O44Kn", + } ); `; @@ -1001,16 +555,7 @@ fbt._( exports[`Test jsx auto-wrapping of implicit parameters should wrap a string next to an explicit that has a implicit within it 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d", - text: "outer string that should not appear in inner desc {explicit fbt param}", - }, - }, - project: "", - } /* __FBT__ end */, + "outer string that should not appear in inner desc {explicit fbt param}", [ fbt._param( "explicit fbt param", @@ -1018,42 +563,29 @@ fbt._( "div", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d2", - text: "explicit fbt param {=with a nested implicit param}", - tokenAliases: { "=with a nested implicit param": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "explicit fbt param {=m1}", [ fbt._implicitParam( "=m1", /*#__PURE__*/ React.createElement( "div", null, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "explicit fbt param {=with a nested implicit param}"', - text: "with a nested implicit param", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("with a nested implicit param", null, { + hk: "47XKzg", + }) ) ), - ] + ], + { + hk: "4aGXvg", + } ) ) ), - ] + ], + { + hk: "1sItWb", + } ); `; @@ -1061,17 +593,7 @@ fbt._( exports[`Test jsx auto-wrapping of implicit parameters should wrap an outer and inner child 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d", - text: "{=this is a doubly} nested test", - tokenAliases: { "=this is a doubly": "=m0" }, - }, - }, - project: "", - } /* __FBT__ end */, + "{=m0} nested test", [ fbt._implicitParam( "=m0", @@ -1081,17 +603,7 @@ fbt._( href: "#", }, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=this is a doubly} nested test"', - text: "{=this is} a doubly", - tokenAliases: { "=this is": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "{=m1} a doubly", [ fbt._implicitParam( "=m1", @@ -1100,25 +612,22 @@ fbt._( { href: "#", }, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=this is} a doubly nested test"', - text: "this is", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("this is", null, { + hk: "24utmg", + }) ) ), - ] + ], + { + hk: "1OBj79", + } ) ) ), - ] + ], + { + hk: "8VKqN", + } ); `; @@ -1126,20 +635,7 @@ fbt._( exports[`Test jsx auto-wrapping of implicit parameters should wrap explicit params nested in implicit params with [] 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d", - text: "{=this is a test [to make sure that explicit params under an implicit node][and ones that are next to each other] under an implicit tag are wrapped with [ ]}{but free standing ones are not}", - tokenAliases: { - "=this is a test [to make sure that explicit params under an implicit node][and ones that are next to each other] under an implicit tag are wrapped with [ ]": - "=m0", - }, - }, - }, - project: "", - } /* __FBT__ end */, + "{=m0}{but free standing ones are not}", [ fbt._param( "but free standing ones are not", @@ -1147,38 +643,22 @@ fbt._( "link", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d3", - text: "but free standing ones {=are not}", - tokenAliases: { "=are not": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "but free standing ones {=m1}", [ fbt._implicitParam( "=m1", /*#__PURE__*/ React.createElement( "b", null, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "but free standing ones {=are not}"', - text: "are not", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("are not", null, { + hk: "cn4P1", + }) ) ), - ] + ], + { + hk: "3vSpVu", + } ) ) ), @@ -1188,16 +668,7 @@ fbt._( "div", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=this is a test [to make sure that explicit params under an implicit node][and ones that are next to each other] under an implicit tag are wrapped with [ ]}{but free standing ones are not}"', - text: "this is a test {to make sure that explicit params under an implicit node}{and ones that are next to each other} under an implicit tag are wrapped with [ ]", - }, - }, - project: "", - } /* __FBT__ end */, + "this is a test {to make sure that explicit params under an implicit node}{and ones that are next to each other} under an implicit tag are wrapped with [ ]", [ fbt._param( "to make sure that explicit params under an implicit node", @@ -1205,38 +676,22 @@ fbt._( "link", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d2", - text: "to make sure that explicit tags {=under an implicit node}", - tokenAliases: { "=under an implicit node": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "to make sure that explicit tags {=m1}", [ fbt._implicitParam( "=m1", /*#__PURE__*/ React.createElement( "b", null, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "to make sure that explicit tags {=under an implicit node}"', - text: "under an implicit node", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("under an implicit node", null, { + hk: "3bb4W4", + }) ) ), - ] + ], + { + hk: "tcca3", + } ) ) ), @@ -1246,46 +701,36 @@ fbt._( "link", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d3", - text: "and ones that are next {=to each other}", - tokenAliases: { "=to each other": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "and ones that are next {=m1}", [ fbt._implicitParam( "=m1", /*#__PURE__*/ React.createElement( "b", null, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "and ones that are next {=to each other}"', - text: "to each other", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("to each other", null, { + hk: "1UQ1NN", + }) ) ), - ] + ], + { + hk: "Z04GD", + } ) ) ), - ] + ], + { + hk: "3J9Kls", + } ) ) ), - ] + ], + { + hk: "25v3pA", + } ); `; @@ -1293,20 +738,7 @@ fbt._( exports[`Test jsx auto-wrapping of implicit parameters should wrap two children with one nested level 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d", - text: "{=this is a doubly} nested test {=with an additional level}", - tokenAliases: { - "=this is a doubly": "=m0", - "=with an additional level": "=m2", - }, - }, - }, - project: "", - } /* __FBT__ end */, + "{=m0} nested test {=m2}", [ fbt._implicitParam( "=m0", @@ -1316,17 +748,7 @@ fbt._( href: "#", }, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=this is a doubly} nested test {=with an additional level}"', - text: "{=this is} a doubly", - tokenAliases: { "=this is": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "{=m1} a doubly", [ fbt._implicitParam( "=m1", @@ -1335,21 +757,15 @@ fbt._( { href: "#", }, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=this is} a doubly nested test {=with an additional level}"', - text: "this is", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("this is", null, { + hk: "1TKqkn", + }) ) ), - ] + ], + { + hk: "36ZVtu", + } ) ) ), @@ -1360,21 +776,15 @@ fbt._( { href: "#", }, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=this is a doubly} nested test {=with an additional level}"', - text: "with an additional level", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("with an additional level", null, { + hk: "3seQMP", + }) ) ), - ] + ], + { + hk: "3gjk4F", + } ); `; @@ -1382,17 +792,7 @@ fbt._( exports[`Test jsx auto-wrapping of implicit parameters should wrap two nested next to each other 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d", - text: "{=one two}{=three four}", - tokenAliases: { "=one two": "=m0", "=three four": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "{=m0}{=m1}", [ fbt._implicitParam( "=m0", @@ -1402,17 +802,7 @@ fbt._( href: "#", }, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=one two}{=three four}"', - text: "one {=two}", - tokenAliases: { "=two": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "one {=m1}", [ fbt._implicitParam( "=m1", @@ -1421,21 +811,15 @@ fbt._( { href: "#", }, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "one {=two}{=three four}"', - text: "two", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("two", null, { + hk: "3iKuUF", + }) ) ), - ] + ], + { + hk: "4adxZQ", + } ) ) ), @@ -1447,17 +831,7 @@ fbt._( href: "#", }, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=one two}{=three four}"', - text: "three {=four}", - tokenAliases: { "=four": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "three {=m1}", [ fbt._implicitParam( "=m1", @@ -1466,25 +840,22 @@ fbt._( { href: "#", }, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=one two}three {=four}"', - text: "four", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("four", null, { + hk: "n5ibk", + }) ) ), - ] + ], + { + hk: "1O7uqf", + } ) ) ), - ] + ], + { + hk: "8Ppxz", + } ); `; @@ -1492,17 +863,7 @@ fbt._( exports[`Test jsx auto-wrapping of implicit parameters should wrap two nested next to each other with an extra level 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d", - text: "{=one two [=test]}{=three four}", - tokenAliases: { "=one two [=test]": "=m0", "=three four": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "{=m0}{=m1}", [ fbt._implicitParam( "=m0", @@ -1512,17 +873,7 @@ fbt._( href: "#", }, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=one two [=test]}{=three four}"', - text: "one {=two test}", - tokenAliases: { "=two test": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "one {=m1}", [ fbt._implicitParam( "=m1", @@ -1532,17 +883,7 @@ fbt._( href: "#", }, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "one {=two test}{=three four}"', - text: "two {=test}", - tokenAliases: { "=test": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "two {=m1}", [ fbt._implicitParam( "=m1", @@ -1551,25 +892,22 @@ fbt._( { href: "#", }, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "one two {=test}{=three four}"', - text: "test", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("test", null, { + hk: "2OdL6Y", + }) ) ), - ] + ], + { + hk: "OL15x", + } ) ) ), - ] + ], + { + hk: "43pnQG", + } ) ) ), @@ -1581,17 +919,7 @@ fbt._( href: "#", }, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=one two [=test]}{=three four}"', - text: "three {=four}", - tokenAliases: { "=four": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "three {=m1}", [ fbt._implicitParam( "=m1", @@ -1600,25 +928,22 @@ fbt._( { href: "#", }, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=one two [=test]}three {=four}"', - text: "four", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("four", null, { + hk: "cB79p", + }) ) ), - ] + ], + { + hk: "2TH8xE", + } ) ) ), - ] + ], + { + hk: "3UXE0m", + } ); `; @@ -1626,35 +951,16 @@ fbt._( exports[`Test jsx auto-wrapping of implicit parameters should wrap two unwrapped children 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d", - text: "{=wrap once}{=wrap twice}", - tokenAliases: { "=wrap once": "=m0", "=wrap twice": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "{=m0}{=m1}", [ fbt._implicitParam( "=m0", /*#__PURE__*/ React.createElement( "div", null, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=wrap once}{=wrap twice}"', - text: "wrap once", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("wrap once", null, { + hk: "1K1zDK", + }) ) ), fbt._implicitParam( @@ -1662,21 +968,15 @@ fbt._( /*#__PURE__*/ React.createElement( "div", null, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=wrap once}{=wrap twice}"', - text: "wrap twice", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("wrap twice", null, { + hk: "1zVLer", + }) ) ), - ] + ], + { + hk: "2NQyTl", + } ); `; @@ -1684,17 +984,7 @@ fbt._( exports[`Test jsx auto-wrapping of implicit parameters should wrap two unwrapped children and 1 nested 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d", - text: "{=wrap once and also}{=wrap twice} complicated", - tokenAliases: { "=wrap once and also": "=m0", "=wrap twice": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "{=m0}{=m1} complicated", [ fbt._implicitParam( "=m0", @@ -1702,38 +992,22 @@ fbt._( "div", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=wrap once and also}{=wrap twice} complicated"', - text: "wrap once {=and also}", - tokenAliases: { "=and also": "=m1" }, - }, - }, - project: "", - } /* __FBT__ end */, + "wrap once {=m1}", [ fbt._implicitParam( "=m1", /*#__PURE__*/ React.createElement( "div", null, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "wrap once {=and also}{=wrap twice} complicated"', - text: "and also", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("and also", null, { + hk: "2aIvXj", + }) ) ), - ] + ], + { + hk: "4nWdli", + } ) ) ), @@ -1742,21 +1016,15 @@ fbt._( /*#__PURE__*/ React.createElement( "div", null, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=wrap once and also}{=wrap twice} complicated"', - text: "wrap twice", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("wrap twice", null, { + hk: "1fMpSn", + }) ) ), - ] + ], + { + hk: "4rDpDG", + } ); `; diff --git a/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbtEnum-test.tsx.snap b/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbtEnum-test.tsx.snap index 1ea9ba45..30dd5eae 100644 --- a/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbtEnum-test.tsx.snap +++ b/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbtEnum-test.tsx.snap @@ -4,18 +4,15 @@ exports[`Test Fbt Enum should handle functional enums (with references) (import import { fbt } from "fbt"; import aEnum from "Test$FbtEnum"; var x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - id1: { desc: "enums!", text: "Click to see groups" }, - id2: { desc: "enums!", text: "Click to see photos" }, - id3: { desc: "enums!", text: "Click to see videos" }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt._enum(id, aEnum)] + { + id1: "Click to see groups", + id2: "Click to see photos", + id3: "Click to see videos", + }, + [fbt._enum(id, aEnum)], + { + hk: "3SHnwE", + } ); `; @@ -24,18 +21,15 @@ exports[`Test Fbt Enum should handle functional enums (with references) (import import { fbt } from "fbt"; import * as aEnum from "Test$FbtEnum"; var x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - id1: { desc: "enums!", text: "Click to see groups" }, - id2: { desc: "enums!", text: "Click to see photos" }, - id3: { desc: "enums!", text: "Click to see videos" }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt._enum(id, aEnum)] + { + id1: "Click to see groups", + id2: "Click to see photos", + id3: "Click to see videos", + }, + [fbt._enum(id, aEnum)], + { + hk: "3SHnwE", + } ); `; @@ -44,18 +38,15 @@ exports[`Test Fbt Enum should handle functional enums (with references) (require import { fbt } from "fbtee"; import aEnum from "Test$FbtEnum"; var x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - id1: { desc: "enums!", text: "Click to see groups" }, - id2: { desc: "enums!", text: "Click to see photos" }, - id3: { desc: "enums!", text: "Click to see videos" }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt._enum(id, aEnum)] + { + id1: "Click to see groups", + id2: "Click to see photos", + id3: "Click to see videos", + }, + [fbt._enum(id, aEnum)], + { + hk: "3SHnwE", + } ); `; @@ -64,18 +55,15 @@ exports[`Test Fbt Enum should handle functional enums (with references) in templ import { fbt } from "fbtee"; import aEnum from "Test$FbtEnum"; var x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - id1: { desc: "enums!", text: "Click to see groups" }, - id2: { desc: "enums!", text: "Click to see photos" }, - id3: { desc: "enums!", text: "Click to see videos" }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt._enum(id, aEnum)] + { + id1: "Click to see groups", + id2: "Click to see photos", + id3: "Click to see videos", + }, + [fbt._enum(id, aEnum)], + { + hk: "3SHnwE", + } ); `; @@ -84,18 +72,15 @@ exports[`Test Fbt Enum should handle jsx enums (with references) 1`] = ` import { fbt } from "fbtee"; import aEnum from "Test$FbtEnum"; var x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - id1: { desc: "enums!", text: "Click to see groups" }, - id2: { desc: "enums!", text: "Click to see photos" }, - id3: { desc: "enums!", text: "Click to see videos" }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt._enum(id, aEnum)] + { + id1: "Click to see groups", + id2: "Click to see photos", + id3: "Click to see videos", + }, + [fbt._enum(id, aEnum)], + { + hk: "3SHnwE", + } ); `; @@ -104,18 +89,15 @@ exports[`Test Fbt Enum should handle jsx string literals 1`] = ` import { fbt } from "fbtee"; import aEnum from "Test$FbtEnum"; var x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - id1: { desc: "enums!", text: "Click to see groups" }, - id2: { desc: "enums!", text: "Click to see photos" }, - id3: { desc: "enums!", text: "Click to see videos" }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt._enum("id1", aEnum)] + { + id1: "Click to see groups", + id2: "Click to see photos", + id3: "Click to see videos", + }, + [fbt._enum("id1", aEnum)], + { + hk: "3SHnwE", + } ); `; diff --git a/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbtPronoun-test.tsx.snap b/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbtPronoun-test.tsx.snap new file mode 100644 index 00000000..6a0114d6 --- /dev/null +++ b/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbtPronoun-test.tsx.snap @@ -0,0 +1,37 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`fbt pronoun support "capitalize" option accepts boolean literal true 1`] = ` +import { fbt } from "fbtee"; +var x = fbt._( + { + 1: "Her birthday is today.", + 2: "His birthday is today.", + "*": "Their birthday is today.", + }, + [fbt._pronoun(1, gender)], + { + hk: "2PfBiX", + } +); + +`; + +exports[`fbt pronoun support Should elide false "human" option from fbt.pronoun() 1`] = ` +import { fbt } from "fbtee"; +var x = fbt._( + { + 1: "Wish her a happy birthday.", + 2: "Wish him a happy birthday.", + "*": "Wish them a happy birthday.", + }, + [ + fbt._pronoun(0, gender, { + human: 1, + }), + ], + { + hk: "YiRZy", + } +); + +`; diff --git a/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbtStaticJSModule-test.tsx.snap b/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbtStaticJSModule-test.tsx.snap index 6a016cda..25d0c57e 100644 --- a/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbtStaticJSModule-test.tsx.snap +++ b/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/fbtStaticJSModule-test.tsx.snap @@ -3,40 +3,16 @@ exports[`fbt preserveWhitespace argument should NOT preserve whitespaces that do not neighbor raw text jsx elements and raw text 1`] = ` import { fbt } from "fbtee"; var x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "d", - text: "{=Where do}{=spaces}{=go?} Good {=question} !", - tokenAliases: { - "=Where do": "=m0", - "=spaces": "=m1", - "=go?": "=m2", - "=question": "=m4", - }, - }, - }, - project: "", - } /* __FBT__ end */, + "{=m0}{=m1}{=m2} Good {=m4} !", [ fbt._implicitParam( "=m0", /*#__PURE__*/ React.createElement( "span", null, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=Where do}{=spaces}{=go?} Good {=question} !"', - text: "Where do", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("Where do", null, { + hk: "2UCUDE", + }) ) ), fbt._implicitParam( @@ -44,18 +20,9 @@ var x = fbt._( /*#__PURE__*/ React.createElement( "b", null, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=Where do}{=spaces}{=go?} Good {=question} !"', - text: "spaces", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("spaces", null, { + hk: "99532", + }) ) ), fbt._implicitParam( @@ -63,18 +30,9 @@ var x = fbt._( /*#__PURE__*/ React.createElement( "i", null, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=Where do}{=spaces}{=go?} Good {=question} !"', - text: "go?", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("go?", null, { + hk: "130kuA", + }) ) ), fbt._implicitParam( @@ -82,21 +40,15 @@ var x = fbt._( /*#__PURE__*/ React.createElement( "i", null, - fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "{=Where do}{=spaces}{=go?} Good {=question} !"', - text: "question", - }, - }, - project: "", - } /* __FBT__ end */ - ) + fbt._("question", null, { + hk: "2K4Jua", + }) ) ), - ] + ], + { + hk: "1hjQfl", + } ); `; @@ -107,32 +59,10 @@ import { fbt } from "fbtee"; var x = ((fbt_sv_arg_0 = fbt._plural(this.state.ex1Count)), fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: "d", - text: "{=OuterJsx1} RawText {=OuterJsx2}{=InnerJsx1(plural)sInnerJsx2}", - tokenAliases: { - "=OuterJsx1": "=m0", - "=OuterJsx2": "=m2", - "=InnerJsx1(plural)sInnerJsx2": "=m3", - }, - }, - _1: { - desc: "d", - text: "{=OuterJsx1} RawText {=OuterJsx2}{=InnerJsx1(plural)InnerJsx2}", - tokenAliases: { - "=OuterJsx1": "=m0", - "=OuterJsx2": "=m2", - "=InnerJsx1(plural)InnerJsx2": "=m3", - }, - }, - }, - }, - project: "", - } /* __FBT__ end */, + { + "*": "{=m0} RawText {=m2}{=m3}", + _1: "{=m0} RawText {=m2}{=m3}", + }, [ fbt_sv_arg_0, fbt._implicitParam( @@ -141,23 +71,14 @@ var x = "a", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1} RawText {=OuterJsx2}{=InnerJsx1(plural)sInnerJsx2}"', - text: "OuterJsx1", - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1} RawText {=OuterJsx2}{=InnerJsx1(plural)InnerJsx2}"', - text: "OuterJsx1", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "OuterJsx1", + _1: "OuterJsx1", + }, + [fbt_sv_arg_0], + { + hk: "3WznBY", + } ) ) ), @@ -167,23 +88,14 @@ var x = "b", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1} RawText {=OuterJsx2}{=InnerJsx1(plural)sInnerJsx2}"', - text: "OuterJsx2", - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1} RawText {=OuterJsx2}{=InnerJsx1(plural)InnerJsx2}"', - text: "OuterJsx2", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "OuterJsx2", + _1: "OuterJsx2", + }, + [fbt_sv_arg_0], + { + hk: "30JSgM", + } ) ) ), @@ -193,24 +105,10 @@ var x = "b", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1} RawText {=OuterJsx2}{=InnerJsx1(plural)sInnerJsx2}"', - text: "{=InnerJsx1}(plural)s{=InnerJsx2}", - tokenAliases: { "=InnerJsx1": "=m1", "=InnerJsx2": "=m3" }, - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1} RawText {=OuterJsx2}{=InnerJsx1(plural)InnerJsx2}"', - text: "{=InnerJsx1}(plural){=InnerJsx2}", - tokenAliases: { "=InnerJsx1": "=m1", "=InnerJsx2": "=m3" }, - }, - }, - }, - project: "", - } /* __FBT__ end */, + { + "*": "{=m1}(plural)s{=m3}", + _1: "{=m1}(plural){=m3}", + }, [ fbt_sv_arg_0, fbt._implicitParam( @@ -219,23 +117,14 @@ var x = "i", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1} RawText {=OuterJsx2}{=InnerJsx1}(plural)s{=InnerJsx2}"', - text: "InnerJsx1", - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1} RawText {=OuterJsx2}{=InnerJsx1}(plural){=InnerJsx2}"', - text: "InnerJsx1", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "InnerJsx1", + _1: "InnerJsx1", + }, + [fbt_sv_arg_0], + { + hk: "24btfK", + } ) ) ), @@ -245,31 +134,28 @@ var x = "i", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1} RawText {=OuterJsx2}{=InnerJsx1}(plural)s{=InnerJsx2}"', - text: "InnerJsx2", - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1} RawText {=OuterJsx2}{=InnerJsx1}(plural){=InnerJsx2}"', - text: "InnerJsx2", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "InnerJsx2", + _1: "InnerJsx2", + }, + [fbt_sv_arg_0], + { + hk: "13rpFP", + } ) ) ), - ] + ], + { + hk: "1Nv3G4", + } ) ) ), - ] + ], + { + hk: "2gHC6Z", + } )); `; @@ -280,27 +166,10 @@ import { fbt } from "fbtee"; var x = ((fbt_sv_arg_0 = fbt._plural(this.state.ex1Count, "number")), fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [{ singular: true, token: "number", type: 2 }], - t: { - "*": { - desc: "d", - text: "{=There should be}{=[number] spaces} !", - tokenAliases: { - "=There should be": "=m0", - "=[number] spaces": "=m1", - }, - }, - _1: { - desc: "d", - text: "{=There should be}{=a space} !", - tokenAliases: { "=There should be": "=m0", "=a space": "=m1" }, - }, - }, - }, - project: "", - } /* __FBT__ end */, + { + "*": "{=m0}{=m1} !", + _1: "{=m0}{=m1} !", + }, [ fbt_sv_arg_0, fbt._implicitParam( @@ -309,23 +178,14 @@ var x = "span", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [{ singular: true, token: "number", type: 2 }], - t: { - "*": { - desc: 'In the phrase: "{=There should be}{=[number] spaces} !"', - text: "There should be", - }, - _1: { - desc: 'In the phrase: "{=There should be}{=a space} !"', - text: "There should be", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "There should be", + _1: "There should be", + }, + [fbt_sv_arg_0], + { + hk: "9ccJh", + } ) ) ), @@ -335,27 +195,21 @@ var x = "b", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [{ singular: true, token: "number", type: 2 }], - t: { - "*": { - desc: 'In the phrase: "{=There should be}{=[number] spaces} !"', - text: "{number} spaces", - }, - _1: { - desc: 'In the phrase: "{=There should be}{=a space} !"', - text: "a space", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "{number} spaces", + _1: "a space", + }, + [fbt_sv_arg_0], + { + hk: "1tuYe0", + } ) ) ), - ] + ], + { + hk: "15ZlDy", + } )); `; @@ -366,34 +220,10 @@ import { fbt } from "fbtee"; var x = ((fbt_sv_arg_0 = fbt._plural(this.state.ex1Count)), fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: "d", - text: "{=OuterJsx1}textInJSXExpression{=OuterJsx2}{=rawText textInJSXExpressionInnerJsx1textInJSXExpression(plural)stextInJSXExpressionInnerJsx2textInJSXExpression}", - tokenAliases: { - "=OuterJsx1": "=m0", - "=OuterJsx2": "=m2", - "=rawText textInJSXExpressionInnerJsx1textInJSXExpression(plural)stextInJSXExpressionInnerJsx2textInJSXExpression": - "=m3", - }, - }, - _1: { - desc: "d", - text: "{=OuterJsx1}textInJSXExpression{=OuterJsx2}{=rawText textInJSXExpressionInnerJsx1textInJSXExpression(plural)textInJSXExpressionInnerJsx2textInJSXExpression}", - tokenAliases: { - "=OuterJsx1": "=m0", - "=OuterJsx2": "=m2", - "=rawText textInJSXExpressionInnerJsx1textInJSXExpression(plural)textInJSXExpressionInnerJsx2textInJSXExpression": - "=m3", - }, - }, - }, - }, - project: "", - } /* __FBT__ end */, + { + "*": "{=m0}textInJSXExpression{=m2}{=m3}", + _1: "{=m0}textInJSXExpression{=m2}{=m3}", + }, [ fbt_sv_arg_0, fbt._implicitParam( @@ -402,23 +232,14 @@ var x = "a", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1}textInJSXExpression{=OuterJsx2}{=rawText textInJSXExpressionInnerJsx1textInJSXExpression(plural)stextInJSXExpressionInnerJsx2textInJSXExpression}"', - text: "OuterJsx1", - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1}textInJSXExpression{=OuterJsx2}{=rawText textInJSXExpressionInnerJsx1textInJSXExpression(plural)textInJSXExpressionInnerJsx2textInJSXExpression}"', - text: "OuterJsx1", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "OuterJsx1", + _1: "OuterJsx1", + }, + [fbt_sv_arg_0], + { + hk: "4i3hty", + } ) ) ), @@ -428,23 +249,14 @@ var x = "b", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1}textInJSXExpression{=OuterJsx2}{=rawText textInJSXExpressionInnerJsx1textInJSXExpression(plural)stextInJSXExpressionInnerJsx2textInJSXExpression}"', - text: "OuterJsx2", - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1}textInJSXExpression{=OuterJsx2}{=rawText textInJSXExpressionInnerJsx1textInJSXExpression(plural)textInJSXExpressionInnerJsx2textInJSXExpression}"', - text: "OuterJsx2", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "OuterJsx2", + _1: "OuterJsx2", + }, + [fbt_sv_arg_0], + { + hk: "gfvaj", + } ) ) ), @@ -454,24 +266,10 @@ var x = "b", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1}textInJSXExpression{=OuterJsx2}{=rawText textInJSXExpressionInnerJsx1textInJSXExpression(plural)stextInJSXExpressionInnerJsx2textInJSXExpression}"', - text: "rawText textInJSXExpression{=InnerJsx1}textInJSXExpression(plural)stextInJSXExpression{=InnerJsx2}textInJSXExpression", - tokenAliases: { "=InnerJsx1": "=m2", "=InnerJsx2": "=m7" }, - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1}textInJSXExpression{=OuterJsx2}{=rawText textInJSXExpressionInnerJsx1textInJSXExpression(plural)textInJSXExpressionInnerJsx2textInJSXExpression}"', - text: "rawText textInJSXExpression{=InnerJsx1}textInJSXExpression(plural)textInJSXExpression{=InnerJsx2}textInJSXExpression", - tokenAliases: { "=InnerJsx1": "=m2", "=InnerJsx2": "=m7" }, - }, - }, - }, - project: "", - } /* __FBT__ end */, + { + "*": "rawText textInJSXExpression{=m2}textInJSXExpression(plural)stextInJSXExpression{=m7}textInJSXExpression", + _1: "rawText textInJSXExpression{=m2}textInJSXExpression(plural)textInJSXExpression{=m7}textInJSXExpression", + }, [ fbt_sv_arg_0, fbt._implicitParam( @@ -480,23 +278,14 @@ var x = "i", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1}textInJSXExpression{=OuterJsx2}rawText textInJSXExpression{=InnerJsx1}textInJSXExpression(plural)stextInJSXExpression{=InnerJsx2}textInJSXExpression"', - text: "InnerJsx1", - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1}textInJSXExpression{=OuterJsx2}rawText textInJSXExpression{=InnerJsx1}textInJSXExpression(plural)textInJSXExpression{=InnerJsx2}textInJSXExpression"', - text: "InnerJsx1", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "InnerJsx1", + _1: "InnerJsx1", + }, + [fbt_sv_arg_0], + { + hk: "1x2Bnp", + } ) ) ), @@ -506,31 +295,28 @@ var x = "i", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1}textInJSXExpression{=OuterJsx2}rawText textInJSXExpression{=InnerJsx1}textInJSXExpression(plural)stextInJSXExpression{=InnerJsx2}textInJSXExpression"', - text: "InnerJsx2", - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1}textInJSXExpression{=OuterJsx2}rawText textInJSXExpression{=InnerJsx1}textInJSXExpression(plural)textInJSXExpression{=InnerJsx2}textInJSXExpression"', - text: "InnerJsx2", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "InnerJsx2", + _1: "InnerJsx2", + }, + [fbt_sv_arg_0], + { + hk: "1xtOBl", + } ) ) ), - ] + ], + { + hk: "20dibT", + } ) ) ), - ] + ], + { + hk: "4f83iT", + } )); `; @@ -541,32 +327,10 @@ import { fbt } from "fbtee"; var x = ((fbt_sv_arg_0 = fbt._plural(this.state.ex1Count)), fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: "d", - text: "{=OuterJsx1} {=OuterJsx2}{=InnerJsx1 (plural)s InnerJsx2 InnerJsx3}", - tokenAliases: { - "=OuterJsx1": "=m0", - "=OuterJsx2": "=m2", - "=InnerJsx1 (plural)s InnerJsx2 InnerJsx3": "=m3", - }, - }, - _1: { - desc: "d", - text: "{=OuterJsx1} {=OuterJsx2}{=InnerJsx1 (plural) InnerJsx2 InnerJsx3}", - tokenAliases: { - "=OuterJsx1": "=m0", - "=OuterJsx2": "=m2", - "=InnerJsx1 (plural) InnerJsx2 InnerJsx3": "=m3", - }, - }, - }, - }, - project: "", - } /* __FBT__ end */, + { + "*": "{=m0} {=m2}{=m3}", + _1: "{=m0} {=m2}{=m3}", + }, [ fbt_sv_arg_0, fbt._implicitParam( @@ -575,23 +339,14 @@ var x = "a", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1} {=OuterJsx2}{=InnerJsx1 (plural)s InnerJsx2 InnerJsx3}"', - text: "OuterJsx1", - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1} {=OuterJsx2}{=InnerJsx1 (plural) InnerJsx2 InnerJsx3}"', - text: "OuterJsx1", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "OuterJsx1", + _1: "OuterJsx1", + }, + [fbt_sv_arg_0], + { + hk: "2mmfyN", + } ) ) ), @@ -601,23 +356,14 @@ var x = "b", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1} {=OuterJsx2}{=InnerJsx1 (plural)s InnerJsx2 InnerJsx3}"', - text: "OuterJsx2", - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1} {=OuterJsx2}{=InnerJsx1 (plural) InnerJsx2 InnerJsx3}"', - text: "OuterJsx2", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "OuterJsx2", + _1: "OuterJsx2", + }, + [fbt_sv_arg_0], + { + hk: "Hdu8h", + } ) ) ), @@ -627,32 +373,10 @@ var x = "b", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1} {=OuterJsx2}{=InnerJsx1 (plural)s InnerJsx2 InnerJsx3}"', - text: "{=InnerJsx1} (plural)s {=InnerJsx2} {=InnerJsx3}", - tokenAliases: { - "=InnerJsx1": "=m2", - "=InnerJsx2": "=m6", - "=InnerJsx3": "=m8", - }, - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1} {=OuterJsx2}{=InnerJsx1 (plural) InnerJsx2 InnerJsx3}"', - text: "{=InnerJsx1} (plural) {=InnerJsx2} {=InnerJsx3}", - tokenAliases: { - "=InnerJsx1": "=m2", - "=InnerJsx2": "=m6", - "=InnerJsx3": "=m8", - }, - }, - }, - }, - project: "", - } /* __FBT__ end */, + { + "*": "{=m2} (plural)s {=m6} {=m8}", + _1: "{=m2} (plural) {=m6} {=m8}", + }, [ fbt_sv_arg_0, fbt._implicitParam( @@ -661,23 +385,14 @@ var x = "i", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1} {=OuterJsx2}{=InnerJsx1} (plural)s {=InnerJsx2} {=InnerJsx3}"', - text: "InnerJsx1", - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1} {=OuterJsx2}{=InnerJsx1} (plural) {=InnerJsx2} {=InnerJsx3}"', - text: "InnerJsx1", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "InnerJsx1", + _1: "InnerJsx1", + }, + [fbt_sv_arg_0], + { + hk: "4C7fcW", + } ) ) ), @@ -687,23 +402,14 @@ var x = "i", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1} {=OuterJsx2}{=InnerJsx1} (plural)s {=InnerJsx2} {=InnerJsx3}"', - text: "InnerJsx2", - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1} {=OuterJsx2}{=InnerJsx1} (plural) {=InnerJsx2} {=InnerJsx3}"', - text: "InnerJsx2", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "InnerJsx2", + _1: "InnerJsx2", + }, + [fbt_sv_arg_0], + { + hk: "3jKBRy", + } ) ) ), @@ -713,31 +419,28 @@ var x = "i", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1} {=OuterJsx2}{=InnerJsx1} (plural)s {=InnerJsx2} {=InnerJsx3}"', - text: "InnerJsx3", - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1} {=OuterJsx2}{=InnerJsx1} (plural) {=InnerJsx2} {=InnerJsx3}"', - text: "InnerJsx3", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "InnerJsx3", + _1: "InnerJsx3", + }, + [fbt_sv_arg_0], + { + hk: "c0FbP", + } ) ) ), - ] + ], + { + hk: "1LC9MD", + } ) ) ), - ] + ], + { + hk: "2mKrhF", + } )); `; @@ -748,32 +451,10 @@ import { fbt } from "fbtee"; var x = ((fbt_sv_arg_0 = fbt._plural(this.state.ex1Count)), fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: "d", - text: "{=OuterJsx1}{=OuterJsx2}{=InnerJsx1(plural)s rawText}", - tokenAliases: { - "=OuterJsx1": "=m0", - "=OuterJsx2": "=m1", - "=InnerJsx1(plural)s rawText": "=m2", - }, - }, - _1: { - desc: "d", - text: "{=OuterJsx1}{=OuterJsx2}{=InnerJsx1(plural) rawText}", - tokenAliases: { - "=OuterJsx1": "=m0", - "=OuterJsx2": "=m1", - "=InnerJsx1(plural) rawText": "=m2", - }, - }, - }, - }, - project: "", - } /* __FBT__ end */, + { + "*": "{=m0}{=m1}{=m2}", + _1: "{=m0}{=m1}{=m2}", + }, [ fbt_sv_arg_0, fbt._implicitParam( @@ -782,23 +463,14 @@ var x = "a", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1}{=OuterJsx2}{=InnerJsx1(plural)s rawText}"', - text: "OuterJsx1", - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1}{=OuterJsx2}{=InnerJsx1(plural) rawText}"', - text: "OuterJsx1", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "OuterJsx1", + _1: "OuterJsx1", + }, + [fbt_sv_arg_0], + { + hk: "1EWqrj", + } ) ) ), @@ -808,23 +480,14 @@ var x = "b", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1}{=OuterJsx2}{=InnerJsx1(plural)s rawText}"', - text: "OuterJsx2", - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1}{=OuterJsx2}{=InnerJsx1(plural) rawText}"', - text: "OuterJsx2", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "OuterJsx2", + _1: "OuterJsx2", + }, + [fbt_sv_arg_0], + { + hk: "wXKn7", + } ) ) ), @@ -834,24 +497,10 @@ var x = "b", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1}{=OuterJsx2}{=InnerJsx1(plural)s rawText}"', - text: "{=InnerJsx1}(plural)s rawText", - tokenAliases: { "=InnerJsx1": "=m2" }, - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1}{=OuterJsx2}{=InnerJsx1(plural) rawText}"', - text: "{=InnerJsx1}(plural) rawText", - tokenAliases: { "=InnerJsx1": "=m2" }, - }, - }, - }, - project: "", - } /* __FBT__ end */, + { + "*": "{=m2}(plural)s rawText", + _1: "{=m2}(plural) rawText", + }, [ fbt_sv_arg_0, fbt._implicitParam( @@ -860,31 +509,28 @@ var x = "i", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "{=OuterJsx1}{=OuterJsx2}{=InnerJsx1}(plural)s rawText"', - text: "InnerJsx1", - }, - _1: { - desc: 'In the phrase: "{=OuterJsx1}{=OuterJsx2}{=InnerJsx1}(plural) rawText"', - text: "InnerJsx1", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "InnerJsx1", + _1: "InnerJsx1", + }, + [fbt_sv_arg_0], + { + hk: "qALb9", + } ) ) ), - ] + ], + { + hk: "48kyWu", + } ) ) ), - ] + ], + { + hk: "4owcY6", + } )); `; @@ -895,30 +541,10 @@ import { fbt } from "fbtee"; var x = ((fbt_sv_arg_0 = fbt._plural(this.state.ex1Count)), fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: "d", - text: "outerText {=outerJsx}{=innerJsx innerText (plural)s}", - tokenAliases: { - "=outerJsx": "=m1", - "=innerJsx innerText (plural)s": "=m2", - }, - }, - _1: { - desc: "d", - text: "outerText {=outerJsx}{=innerJsx innerText (plural)}", - tokenAliases: { - "=outerJsx": "=m1", - "=innerJsx innerText (plural)": "=m2", - }, - }, - }, - }, - project: "", - } /* __FBT__ end */, + { + "*": "outerText {=m1}{=m2}", + _1: "outerText {=m1}{=m2}", + }, [ fbt_sv_arg_0, fbt._implicitParam( @@ -927,23 +553,14 @@ var x = "a", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "outerText {=outerJsx}{=innerJsx innerText (plural)s}"', - text: "outerJsx", - }, - _1: { - desc: 'In the phrase: "outerText {=outerJsx}{=innerJsx innerText (plural)}"', - text: "outerJsx", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "outerJsx", + _1: "outerJsx", + }, + [fbt_sv_arg_0], + { + hk: "1UvHDM", + } ) ) ), @@ -953,24 +570,10 @@ var x = "b", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "outerText {=outerJsx}{=innerJsx innerText (plural)s}"', - text: "{=innerJsx} innerText (plural)s", - tokenAliases: { "=innerJsx": "=m1" }, - }, - _1: { - desc: 'In the phrase: "outerText {=outerJsx}{=innerJsx innerText (plural)}"', - text: "{=innerJsx} innerText (plural)", - tokenAliases: { "=innerJsx": "=m1" }, - }, - }, - }, - project: "", - } /* __FBT__ end */, + { + "*": "{=m1} innerText (plural)s", + _1: "{=m1} innerText (plural)", + }, [ fbt_sv_arg_0, fbt._implicitParam( @@ -979,31 +582,28 @@ var x = "i", null, fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - "*": { - desc: 'In the phrase: "outerText {=outerJsx}{=innerJsx} innerText (plural)s"', - text: "innerJsx", - }, - _1: { - desc: 'In the phrase: "outerText {=outerJsx}{=innerJsx} innerText (plural)"', - text: "innerJsx", - }, - }, - }, - project: "", - } /* __FBT__ end */, - [fbt_sv_arg_0] + { + "*": "innerJsx", + _1: "innerJsx", + }, + [fbt_sv_arg_0], + { + hk: "3AsEj4", + } ) ) ), - ] + ], + { + hk: "3aHsRR", + } ) ) ), - ] + ], + { + hk: "1K3ejM", + } )); `; diff --git a/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/jsx-test.tsx.snap b/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/jsx-test.tsx.snap index b5e8981c..603b812a 100644 --- a/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/jsx-test.tsx.snap +++ b/packages/babel-plugin-fbtee/src/__tests__/__snapshots__/jsx-test.tsx.snap @@ -3,42 +3,29 @@ exports[`Test declarative (jsx) fbt syntax translation Enable explicit whitespace 1`] = ` import { fbt } from "fbtee"; var x = fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "squelched", text: "{one} {two} {three}" } }, - project: "", - } /* __FBT__ end */, - [fbt._param("one", one), fbt._param("two", two), fbt._param("three", three)] + "{one} {two} {three}", + [fbt._param("one", one), fbt._param("two", two), fbt._param("three", three)], + { + hk: "1AF7e1", + } ); `; exports[`Test declarative (jsx) fbt syntax translation Squelch whitespace when in an expression 1`] = ` import { fbt } from "fbtee"; -var x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "squelched", - text: "Squelched white space... with some other stuff.", - }, - }, - project: "", - } /* __FBT__ end */ -); +var x = fbt._("Squelched white space... with some other stuff.", null, { + hk: "UtpyE", +}); baz(); `; exports[`Test declarative (jsx) fbt syntax translation fbt:param with multiple empty expression containers should be ok 1`] = ` import { fbt } from "fbtee"; -fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "some-desc", text: "{foo}" } }, - project: "", - } /* __FBT__ end */, - [fbt._param("foo", foo)] -); +fbt._("{foo}", [fbt._param("foo", foo)], { + hk: "2kCEE7", +}); `; @@ -46,10 +33,7 @@ exports[`Test declarative (jsx) fbt syntax translation should be able to house a import { fbt } from "fbtee";
{fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "...", text: "{time} by {user name}" } }, - project: "", - } /* __FBT__ end */, + "{time} by {user name}", [ fbt._param("time", formatDate(date, "F d, Y")), fbt._param( @@ -62,7 +46,10 @@ import { fbt } from "fbtee"; {user.name} ), - ] + ], + { + hk: "1KGso4", + } )}
; @@ -72,12 +59,9 @@ exports[`Test declarative (jsx) fbt syntax translation should be able to nest wi import { fbt } from "fbtee"; var x = (
- {fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "nested!", text: "A nested string" } }, - project: "", - } /* __FBT__ end */ - )} + {fbt._("A nested string", null, { + hk: "2Z1yyy", + })}
); @@ -85,86 +69,58 @@ var x = ( exports[`Test declarative (jsx) fbt syntax translation should convert simple strings 1`] = ` import { fbt } from "fbtee"; -var x = fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "It's simple", text: "A simple string" } }, - project: "", - } /* __FBT__ end */ -); +var x = fbt._("A simple string", null, { + hk: "pITkM", +}); `; exports[`Test declarative (jsx) fbt syntax translation should correctly destruct expression values in options 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [{ token: "count", type: 2 }], - t: { "*": { desc: "d", text: "str {count}" } }, - }, - project: "", - } /* __FBT__ end */, - [fbt._param("count", getNum(), [0, someNum])] + { + "*": "str {count}", + }, + [fbt._param("count", getNum(), [0, someNum])], + { + hk: "A8zRg", + } ); `; exports[`Test declarative (jsx) fbt syntax translation should filter comment and empty expressions from children 1`] = ` import { fbt } from "fbtee"; -var x = fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "It's simple", text: "A simple string" } }, - project: "", - } /* __FBT__ end */ -); +var x = fbt._("A simple string", null, { + hk: "pITkM", +}); `; exports[`Test declarative (jsx) fbt syntax translation should handle common string 1`] = ` import { fbt } from "fbtee"; -fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { desc: 'The description for the common string "Done"', text: "Done" }, - }, - project: "", - } /* __FBT__ end */ -); +fbt._("Done", null, { + hk: "3wsyxm", +}); `; exports[`Test declarative (jsx) fbt syntax translation should handle concatenated descriptions 1`] = ` import { fbt } from "fbtee"; -fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "A very long description that we will concatenate a few times", - text: "Here it is", - }, - }, - project: "Withaproject", - } /* __FBT__ end */ -); +fbt._("Here it is", null, { + hk: "bwmzh", +}); `; exports[`Test declarative (jsx) fbt syntax translation should handle empty string 1`] = ` import { fbt } from "fbtee"; var x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "a message!", - text: "A parameterized message to: {emptyString}", - }, - }, - project: "", - } /* __FBT__ end */, - [fbt._param("emptyString", " ")] + "A parameterized message to: {emptyString}", + [fbt._param("emptyString", " ")], + { + hk: "1k5iwm", + } ); `; @@ -172,24 +128,21 @@ var x = fbt._( exports[`Test declarative (jsx) fbt syntax translation should handle enums (with array values) 1`] = ` import { fbt } from "fbtee"; var x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - groups: { desc: "enums!", text: "Click to see groups" }, - photos: { desc: "enums!", text: "Click to see photos" }, - videos: { desc: "enums!", text: "Click to see videos" }, - }, - }, - project: "", - } /* __FBT__ end */, + { + groups: "Click to see groups", + photos: "Click to see photos", + videos: "Click to see videos", + }, [ fbt._enum(id, { groups: "groups", photos: "photos", videos: "videos", }), - ] + ], + { + hk: "2bHIKd", + } ); `; @@ -197,24 +150,21 @@ var x = fbt._( exports[`Test declarative (jsx) fbt syntax translation should handle enums (with object values) 1`] = ` import { fbt } from "fbtee"; var x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - id1: { desc: "enums!", text: "Click to see groups" }, - id2: { desc: "enums!", text: "Click to see photos" }, - id3: { desc: "enums!", text: "Click to see videos" }, - }, - }, - project: "", - } /* __FBT__ end */, + { + id1: "Click to see groups", + id2: "Click to see photos", + id3: "Click to see videos", + }, [ fbt._enum(id, { id1: "groups", id2: "photos", id3: "videos", }), - ] + ], + { + hk: "3SHnwE", + } ); `; @@ -222,53 +172,43 @@ var x = fbt._( exports[`Test declarative (jsx) fbt syntax translation should handle enums with more text 1`] = ` import { fbt } from "fbtee"; var x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - id1: { desc: "enums!", text: "Click to see groups Hey-hey!" }, - id2: { desc: "enums!", text: "Click to see photos Hey-hey!" }, - id3: { desc: "enums!", text: "Click to see videos Hey-hey!" }, - }, - }, - project: "", - } /* __FBT__ end */, + { + id1: "Click to see groups Hey-hey!", + id2: "Click to see photos Hey-hey!", + id3: "Click to see videos Hey-hey!", + }, [ fbt._enum(id, { id1: "groups", id2: "photos", id3: "videos", }), - ] + ], + { + hk: "328Iya", + } ); `; exports[`Test declarative (jsx) fbt syntax translation should handle fbt common attribute without value 1`] = ` import { fbt } from "fbtee"; -fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { desc: 'The description for the common string "Okay"', text: "Okay" }, - }, - project: "", - } /* __FBT__ end */ -); +fbt._("Okay", null, { + hk: "2aLqR1", +}); `; exports[`Test declarative (jsx) fbt syntax translation should handle number={true} - (same output as above test) 1`] = ` import { fbt } from "fbtee"; var x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [{ token: "count", type: 2 }], - t: { "*": { desc: "variations!", text: "Click to see {count} links" } }, - }, - project: "", - } /* __FBT__ end */, - [fbt._param("count", c, [0])] + { + "*": "Click to see {count} links", + }, + [fbt._param("count", c, [0])], + { + hk: "35KbmT", + } ); `; @@ -276,19 +216,16 @@ var x = fbt._( exports[`Test declarative (jsx) fbt syntax translation should handle object pronoun 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null], - t: { - 0: { desc: "d", text: "I know this." }, - 1: { desc: "d", text: "I know her." }, - 2: { desc: "d", text: "I know him." }, - "*": { desc: "d", text: "I know them." }, - }, - }, - project: "p", - } /* __FBT__ end */, - [fbt._pronoun(0, gender)] + { + 0: "I know this.", + 1: "I know her.", + 2: "I know him.", + "*": "I know them.", + }, + [fbt._pronoun(0, gender)], + { + hk: "19l1pH", + } ); `; @@ -296,48 +233,37 @@ fbt._( exports[`Test declarative (jsx) fbt syntax translation should handle params 1`] = ` import { fbt } from "fbtee"; var x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "a message!", - text: "A parameterized message to: {personName}", - }, - }, - project: "", - } /* __FBT__ end */, - [fbt._param("personName", theName)] + "A parameterized message to: {personName}", + [fbt._param("personName", theName)], + { + hk: "2ArYIU", + } ); `; exports[`Test declarative (jsx) fbt syntax translation should handle single expression with concentated strings 1`] = ` import { fbt } from "fbtee"; -fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "foo", text: "foobar" } }, - project: "", - } /* __FBT__ end */ -); +fbt._("foobar", null, { + hk: "4l7JLw", +}); `; exports[`Test declarative (jsx) fbt syntax translation should handle subject+reflexive pronouns 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null, null], - t: { - 1: { 1: { desc: "d", text: "She wished herself a happy birthday." } }, - 2: { 2: { desc: "d", text: "He wished himself a happy birthday." } }, - "*": { - "*": { desc: "d", text: "They wished themselves a happy birthday." }, - }, - }, + { + 1: { + 1: "She wished herself a happy birthday.", + }, + 2: { + 2: "He wished himself a happy birthday.", + }, + "*": { + "*": "They wished themselves a happy birthday.", }, - project: "p", - } /* __FBT__ end */, + }, [ fbt._pronoun(3, gender, { human: 1, @@ -345,92 +271,71 @@ fbt._( fbt._pronoun(2, gender, { human: 1, }), - ] + ], + { + hk: "3hCKKE", + } ); `; exports[`Test declarative (jsx) fbt syntax translation should handle template descriptions 1`] = ` import { fbt } from "fbtee"; -fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "A very long description that will be a template across multiple lines", - text: "Here it is", - }, - }, - project: "Withaproject", - } /* __FBT__ end */ -); +fbt._("Here it is", null, { + hk: "124XBa", +}); `; exports[`Test declarative (jsx) fbt syntax translation should handle variations 1`] = ` import { fbt } from "fbtee"; var x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [{ token: "count", type: 2 }], - t: { "*": { desc: "variations!", text: "Click to see {count} links" } }, - }, - project: "", - } /* __FBT__ end */, - [fbt._param("count", c, [0])] + { + "*": "Click to see {count} links", + }, + [fbt._param("count", c, [0])], + { + hk: "35KbmT", + } ); `; exports[`Test declarative (jsx) fbt syntax translation should ignore __private attributes 1`] = ` import { fbt } from "fbtee"; -fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "some-desc", text: "{foo}" } }, - project: "", - } /* __FBT__ end */, - [fbt._param("foo", foo)] -); +fbt._("{foo}", [fbt._param("foo", foo)], { + hk: "2kCEE7", +}); `; exports[`Test declarative (jsx) fbt syntax translation should ignore non-expression children in fbt:param 1`] = ` import { fbt } from "fbtee"; -fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "some-desc", text: "{foo}" } }, - project: "", - } /* __FBT__ end */, - [fbt._param("foo", foo)] -); +fbt._("{foo}", [fbt._param("foo", foo)], { + hk: "2kCEE7", +}); `; exports[`Test declarative (jsx) fbt syntax translation should insert param value for same-param 1`] = ` import { fbt } from "fbtee"; -fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "d", text: "str {foo} and {foo}" } }, - project: "", - } /* __FBT__ end */, - [fbt._param("foo", Bar)] -); +fbt._("str {foo} and {foo}", [fbt._param("foo", Bar)], { + hk: "4oznc3", +}); `; exports[`Test declarative (jsx) fbt syntax translation should maintain order of params and enums 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null, { token: "bar", type: 2 }], - t: { - x: { "*": { desc: "some-desc", text: "Hello, {foo}x{bar}" } }, - y: { "*": { desc: "some-desc", text: "Hello, {foo}y{bar}" } }, - }, + { + x: { + "*": "Hello, {foo}x{bar}", + }, + y: { + "*": "Hello, {foo}y{bar}", }, - project: "", - } /* __FBT__ end */, + }, [ fbt._enum(x, { x: "x", @@ -438,88 +343,53 @@ fbt._( }), fbt._param("bar", bar, [0, n]), fbt._param("foo", foo), - ] + ], + { + hk: "jYMse", + } ); `; exports[`Test declarative (jsx) fbt syntax translation should not insert extra space 1`] = ` import { fbt } from "fbtee"; -fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { desc: "Greating in i18n demo", text: "Hello, {guest}!" }, - }, - project: "", - } /* __FBT__ end */, - [fbt._param("guest", guest)] -); +fbt._("Hello, {guest}!", [fbt._param("guest", guest)], { + hk: "21cLqh", +}); `; exports[`Test declarative (jsx) fbt syntax translation should strip out more newlines 1`] = ` import { fbt } from "fbtee"; -var x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "moar lines", - text: "A simple string... with some other stuff.", - }, - }, - project: "", - } /* __FBT__ end */ -); +var x = fbt._("A simple string... with some other stuff.", null, { + hk: "xpi1d", +}); baz(); `; exports[`Test declarative (jsx) fbt syntax translation should strip out newlines 1`] = ` import { fbt } from "fbtee"; -var x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "Test trailing space when not last child", - text: "Preamble {parm}", - }, - }, - project: "", - } /* __FBT__ end */, - [fbt._param("parm", blah)] -); +var x = fbt._("Preamble {parm}", [fbt._param("parm", blah)], { + hk: "42eUy1", +}); baz(); `; exports[`Test declarative (jsx) fbt syntax translation should support html escapes 1`] = ` import { fbt } from "fbtee"; -fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: 'foo "bar"', text: "×" } }, - project: "", - } /* __FBT__ end */ -); +fbt._("×", null, { + hk: "2jQoIS", +}); `; exports[`Test declarative (jsx) fbt syntax translation should support non-breasking space character 1`] = ` import { fbt } from "fbtee"; -fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "desc with non-breaking   space", - text: "text with non-breaking   space", - }, - }, - project: "", - } /* __FBT__ end */ -); +fbt._("text with non-breaking   space", null, { + hk: "1WqZ9A", +}); `; @@ -527,34 +397,20 @@ exports[`Test declarative (jsx) fbt syntax translation should support unicode ch import { fbt } from "fbtee"; // A backslash \\ in comments fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "unicode characters", - text: "A copyright sign ©, a multi byte character 💩, and a backslash \\\\.", - }, - }, - project: "", - } /* __FBT__ end */ + "A copyright sign ©, a multi byte character 💩, and a backslash \\\\.", + null, + { + hk: "4w0iJW", + } ); `; exports[`Test declarative (jsx) fbt syntax translation should treat multiline descs as a single line 1`] = ` import { fbt } from "fbtee"; -fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "hi how are you today im doing well i guess how is your mother is she well yeah why not lets go home and never come back.", - text: "lol", - }, - }, - project: "", - } /* __FBT__ end */ -); +fbt._("lol", null, { + hk: "1kGA01", +}); `; @@ -562,10 +418,7 @@ exports[`Test declarative (jsx) fbt syntax translation should work with fragment import { fbt } from "fbtee"; {fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "...", text: "{time} by {user name}" } }, - project: "", - } /* __FBT__ end */, + "{time} by {user name}", [ fbt._param("time", formatDate(date, "F d, Y")), fbt._param( @@ -578,7 +431,10 @@ import { fbt } from "fbtee"; {user.name} ), - ] + ], + { + hk: "1KGso4", + } )} ; @@ -588,10 +444,7 @@ exports[`Test declarative (jsx) fbt syntax translation should work with implicit import { fbt } from "fbtee"; <> {fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "...", text: "{time} by {user name}" } }, - project: "", - } /* __FBT__ end */, + "{time} by {user name}", [ fbt._param("time", formatDate(date, "F d, Y")), fbt._param( @@ -604,7 +457,10 @@ import { fbt } from "fbtee"; {user.name} ), - ] + ], + { + hk: "1KGso4", + } )} ; @@ -613,17 +469,18 @@ import { fbt } from "fbtee"; exports[`Test fbt transforms without the jsx transform [legacy buggy behavior] should insert a space character between two fbt constructs that don't neighbor raw text 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null, null], - t: { - "*": { "*": { desc: "", text: "You can add thesetags to anything." } }, - _1: { _1: { desc: "", text: "You can add this tag to anything." } }, - }, + { + "*": { + "*": "You can add thesetags to anything.", }, - project: "", - } /* __FBT__ end */, - [fbt._plural(count), fbt._plural(count)] + _1: { + _1: "You can add this tag to anything.", + }, + }, + [fbt._plural(count), fbt._plural(count)], + { + hk: "1kDgt0", + } ); `; @@ -632,12 +489,9 @@ exports[`Test fbt transforms without the jsx transform nested in div 1`] = ` import { fbt } from "fbtee"; let x = (
- {fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "nested!", text: "A nested string" } }, - project: "", - } /* __FBT__ end */ - )} + {fbt._("A nested string", null, { + hk: "2Z1yyy", + })}
); @@ -645,72 +499,57 @@ let x = ( exports[`Test fbt transforms without the jsx transform not nested 1`] = ` import { fbt } from "fbtee"; -let x = fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "nested!", text: "A nested string" } }, - project: "", - } /* __FBT__ end */ -); +let x = fbt._("A nested string", null, { + hk: "2Z1yyy", +}); `; exports[`Test fbt transforms without the jsx transform short bool syntax for doNotExtract attribute 1`] = ` import { fbt } from "fbtee"; -let x = fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "", text: "Test" } }, - project: "", - } /* __FBT__ end */ -); +let x = fbt._("Test", null, { + hk: "2XNFBa", +}); `; exports[`Test fbt transforms without the jsx transform short bool syntax for number attribute 1`] = ` import { fbt } from "fbtee"; let x = fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [{ token: "name", type: 2 }], - t: { "*": { desc: "", text: "{name}" } }, - }, - project: "", - } /* __FBT__ end */, - [fbt._param("name", "name", [0])] + { + "*": "{name}", + }, + [fbt._param("name", "name", [0])], + { + hk: "1SNt5t", + } ); `; exports[`Test fbt transforms without the jsx transform should fail to preserve whitespace in text when preserveWhitespace=true (known bug) 1`] = ` import { fbt } from "fbtee"; -fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "desc with 3 spaces", - text: "Some text with 3 spaces in between.", - }, - }, - project: "", - } /* __FBT__ end */ -); +fbt._("Some text with 3 spaces in between.", null, { + hk: "3Uwc3D", +}); `; exports[`Test fbt transforms without the jsx transform when using within template literals should dedupe plurals 1`] = ` import { fbt } from "fbtee"; fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [null, { singular: true, token: "number", type: 2 }], - t: { - "*": { "*": { desc: "desc...", text: "There are {number} photos." } }, - _1: { _1: { desc: "desc...", text: "There is 1 photo." } }, - }, + { + "*": { + "*": "There are {number} photos.", }, - project: "", - } /* __FBT__ end */, - [fbt._plural(num), fbt._plural(num, "number", hi())] + _1: { + _1: "There is 1 photo.", + }, + }, + [fbt._plural(num), fbt._plural(num, "number", hi())], + { + hk: "2DWyfC", + } ); `; @@ -718,12 +557,9 @@ fbt._( exports[`Test fbt transforms without the jsx transform when using within template literals should work with a basic 1`] = ` import { fbt } from "fbtee"; html\`
- \${fbt._( - /* __FBT__ start */ { - jsfbt: { m: [], t: { desc: "some desc", text: "basic text" } }, - project: "some project", - } /* __FBT__ end */ - )} + \${fbt._("basic text", null, { + hk: "10IXnM", + })}
\`; `; @@ -732,30 +568,24 @@ exports[`Test fbt transforms without the jsx transform when using within templat import { fbt } from "fbtee"; html\`
\${fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { desc: "some desc", text: "outer text {param text}" }, - }, - project: "some project", - } /* __FBT__ end */, + "outer text {param text}", [ fbt._param( "param text", html\` \${fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { desc: "inner string", text: "inner text {inner param}" }, - }, - project: "", - } /* __FBT__ end */, - [fbt._param("inner param", "bold")] + "inner text {inner param}", + [fbt._param("inner param", "bold")], + { + hk: "koRSf", + } )} \` ), - ] + ], + { + hk: "3keHFG", + } )}
\`; @@ -765,36 +595,20 @@ exports[`Test fbt transforms without the jsx transform when using within templat import { fbt } from "fbtee"; html\`
\${fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: "some desc", - text: "outer text {=bold text}", - tokenAliases: { "=bold text": "=m1" }, - }, - }, - project: "some project", - } /* __FBT__ end */, + "outer text {=m1}", [ fbt._implicitParam( "=m1", - {fbt._( - /* __FBT__ start */ { - jsfbt: { - m: [], - t: { - desc: 'In the phrase: "outer text {=bold text}"', - text: "bold text", - }, - }, - project: "some project", - } /* __FBT__ end */ - )} + {fbt._("bold text", null, { + hk: "3GKUYj", + })} ), - ] + ], + { + hk: "4BN0aO", + } )}
\`; diff --git a/packages/babel-plugin-fbtee/src/__tests__/fbtPronoun-test.tsx b/packages/babel-plugin-fbtee/src/__tests__/fbtPronoun-test.tsx index 98d2d4b6..e900cd12 100644 --- a/packages/babel-plugin-fbtee/src/__tests__/fbtPronoun-test.tsx +++ b/packages/babel-plugin-fbtee/src/__tests__/fbtPronoun-test.tsx @@ -1,57 +1,26 @@ -import { PluginOptions } from '@babel/core'; import { describe, expect, it } from '@jest/globals'; import { - assertSourceAstEqual, - payload, + jsCodeFbtCallSerializer, + snapshotTransform, transform, withFbtImportStatement, } from './FbtTestUtil.tsx'; -function runTest( - data: { input: string; output: string }, - extra?: PluginOptions, -) { - const expected = data.output; - const actual = transform(data.input, extra); - assertSourceAstEqual(expected, actual); -} +expect.addSnapshotSerializer(jsCodeFbtCallSerializer); describe('fbt pronoun support', () => { it('"capitalize" option accepts boolean literal true', () => { - runTest({ - input: withFbtImportStatement( - `var x = fbt( - fbt.pronoun('possessive', gender, {capitalize: true}) + - ' birthday is today.', - 'Capitalized possessive pronoun', - );`, - ), - - output: withFbtImportStatement( - `var x = fbt._( - ${payload({ - jsfbt: { - m: [null], - t: { - '*': { - desc: 'Capitalized possessive pronoun', - text: 'Their birthday is today.', - }, - 1: { - desc: 'Capitalized possessive pronoun', - text: 'Her birthday is today.', - }, - 2: { - desc: 'Capitalized possessive pronoun', - text: 'His birthday is today.', - }, - }, - }, - })}, - [fbt._pronoun(1, gender)], + expect( + snapshotTransform( + withFbtImportStatement( + `var x = fbt( + fbt.pronoun('possessive', gender, {capitalize: true}) + + ' birthday is today.', + 'Capitalized possessive pronoun', );`, + ), ), - }); + ).toMatchSnapshot(); }); it('Should throw when using non-Boolean option value', () => { @@ -101,42 +70,18 @@ describe('fbt pronoun support', () => { }); it('Should elide false "human" option from fbt.pronoun()', () => { - runTest({ - input: + expect( + snapshotTransform( // I.e. Wish them a happy birthday. withFbtImportStatement( `var x = fbt( - 'Wish ' + - fbt.pronoun('object', gender, {human: true}) + - ' a happy birthday.', - 'Elided false option', - );`, - ), - - output: withFbtImportStatement( - `var x = fbt._( - ${payload({ - jsfbt: { - m: [null], - t: { - '*': { - desc: 'Elided false option', - text: 'Wish them a happy birthday.', - }, - 1: { - desc: 'Elided false option', - text: 'Wish her a happy birthday.', - }, - 2: { - desc: 'Elided false option', - text: 'Wish him a happy birthday.', - }, - }, - }, - })}, - [fbt._pronoun(0, gender, {human: 1})], + 'Wish ' + + fbt.pronoun('object', gender, {human: true}) + + ' a happy birthday.', + 'Elided false option', );`, + ), ), - }); + ).toMatchSnapshot(); }); });