Skip to content

Commit

Permalink
change test format
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkoreye committed Jan 16, 2025
1 parent 4d4af28 commit 6b92976
Show file tree
Hide file tree
Showing 2 changed files with 166 additions and 159 deletions.
308 changes: 154 additions & 154 deletions packages/core/src/__tests__/__snapshots__/builder.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4187,6 +4187,158 @@ export default function MyComponent(props) {
`;
exports[`Builder > localization 3`] = `
{
"data": {
"blocks": [
{
"@type": "@builder.io/sdk:Element",
"actions": {},
"bindings": {},
"children": [
{
"@type": "@builder.io/sdk:Element",
"bindings": {},
"component": {
"name": "Text",
"options": {
"text": "<p>Time left: {{state.timeLeft}} seconds</p>",
},
},
"tagName": "span",
},
],
"code": {
"actions": {},
"bindings": {},
},
"properties": {},
"tagName": "div",
},
{
"@type": "@builder.io/sdk:Element",
"actions": {},
"bindings": {},
"children": [
{
"@type": "@builder.io/sdk:Element",
"bindings": {},
"component": {
"name": "Text",
"options": {
"text": {
"@type": "@builder.io/core:LocalizedValue",
"Default": "<p>hello default</p>",
"es-AR": "<p>hello argentina</p>",
"fr-CA": "<p>hello france</p><p><br></p>",
},
},
},
"tagName": "span",
},
],
"code": {
"actions": {},
"bindings": {},
},
"properties": {},
"tagName": "div",
},
{
"@type": "@builder.io/sdk:Element",
"actions": {},
"bindings": {},
"children": [],
"code": {
"actions": {},
"bindings": {},
},
"component": {
"name": "Image",
"options": {
"image": {
"@type": "@builder.io/core:LocalizedValue",
"Default": "https://cdn.builder.io/api/v1/image/placeholder?default",
"es-AR": "https://cdn.builder.io/api/v1/image/placeholder?es-ar",
"fr-CA": "https://cdn.builder.io/api/v1/image/placeholder?fr-ca",
},
},
},
},
{
"@type": "@builder.io/sdk:Element",
"actions": {},
"bindings": {},
"children": [],
"code": {
"actions": {},
"bindings": {},
},
"component": {
"name": "CustomComponent",
"options": {
"title": {
"@type": "@builder.io/core:LocalizedValue",
"Default": "<p>hello default</p>",
"es-AR": "<p>hello argentina</p>",
"fr-CA": "<p>hello france</p><p><br></p>",
},
},
},
},
{
"@type": "@builder.io/sdk:Element",
"actions": {},
"bindings": {
"component.options.scriptsClientOnly": "false",
},
"children": [],
"code": {
"actions": {},
"bindings": {
"component.options.scriptsClientOnly": "false",
},
},
"component": {
"name": "Custom Code",
"options": {
"builderTag": "a",
"code": "<a>Link</a>
",
"href": "http://builder.io",
"scriptsClientOnly": false,
},
},
"linkUrl": {
"@type": "@builder.io/core:LocalizedValue",
"Default": "http://builder.io",
},
"properties": {
"href": {
"@type": "@builder.io/core:LocalizedValue",
"Default": "http://builder.io",
},
},
"responsiveStyles": {
"large": {
"boxSizing": "border-box",
"cursor": "pointer",
"display": "flex",
"flexDirection": "column",
"flexShrink": "0",
"marginTop": "20px",
"pointerEvents": "auto",
"position": "relative",
},
},
},
],
"jsCode": "",
"tsCode": "",
},
}
`;
exports[`Builder > localization preserve text blocks 1`] = `
{
"@type": "@builder.io/mitosis/component",
"children": [
Expand Down Expand Up @@ -4353,7 +4505,7 @@ exports[`Builder > localization 3`] = `
}
`;
exports[`Builder > localization 4`] = `
exports[`Builder > localization preserve text blocks 2`] = `
"import { Image, CustomComponent, CustomCode } from \\"@components\\";
export default function MyComponent(props) {
Expand Down Expand Up @@ -4394,159 +4546,7 @@ export default function MyComponent(props) {
"
`;
exports[`Builder > localization 5`] = `
{
"data": {
"blocks": [
{
"@type": "@builder.io/sdk:Element",
"actions": {},
"bindings": {},
"children": [
{
"@type": "@builder.io/sdk:Element",
"bindings": {},
"component": {
"name": "Text",
"options": {
"text": "<p>Time left: {{state.timeLeft}} seconds</p>",
},
},
"tagName": "span",
},
],
"code": {
"actions": {},
"bindings": {},
},
"properties": {},
"tagName": "div",
},
{
"@type": "@builder.io/sdk:Element",
"actions": {},
"bindings": {},
"children": [
{
"@type": "@builder.io/sdk:Element",
"bindings": {},
"component": {
"name": "Text",
"options": {
"text": {
"@type": "@builder.io/core:LocalizedValue",
"Default": "<p>hello default</p>",
"es-AR": "<p>hello argentina</p>",
"fr-CA": "<p>hello france</p><p><br></p>",
},
},
},
"tagName": "span",
},
],
"code": {
"actions": {},
"bindings": {},
},
"properties": {},
"tagName": "div",
},
{
"@type": "@builder.io/sdk:Element",
"actions": {},
"bindings": {},
"children": [],
"code": {
"actions": {},
"bindings": {},
},
"component": {
"name": "Image",
"options": {
"image": {
"@type": "@builder.io/core:LocalizedValue",
"Default": "https://cdn.builder.io/api/v1/image/placeholder?default",
"es-AR": "https://cdn.builder.io/api/v1/image/placeholder?es-ar",
"fr-CA": "https://cdn.builder.io/api/v1/image/placeholder?fr-ca",
},
},
},
},
{
"@type": "@builder.io/sdk:Element",
"actions": {},
"bindings": {},
"children": [],
"code": {
"actions": {},
"bindings": {},
},
"component": {
"name": "CustomComponent",
"options": {
"title": {
"@type": "@builder.io/core:LocalizedValue",
"Default": "<p>hello default</p>",
"es-AR": "<p>hello argentina</p>",
"fr-CA": "<p>hello france</p><p><br></p>",
},
},
},
},
{
"@type": "@builder.io/sdk:Element",
"actions": {},
"bindings": {
"component.options.scriptsClientOnly": "false",
},
"children": [],
"code": {
"actions": {},
"bindings": {
"component.options.scriptsClientOnly": "false",
},
},
"component": {
"name": "Custom Code",
"options": {
"builderTag": "a",
"code": "<a>Link</a>
",
"href": "http://builder.io",
"scriptsClientOnly": false,
},
},
"linkUrl": {
"@type": "@builder.io/core:LocalizedValue",
"Default": "http://builder.io",
},
"properties": {
"href": {
"@type": "@builder.io/core:LocalizedValue",
"Default": "http://builder.io",
},
},
"responsiveStyles": {
"large": {
"boxSizing": "border-box",
"cursor": "pointer",
"display": "flex",
"flexDirection": "column",
"flexShrink": "0",
"marginTop": "20px",
"pointerEvents": "auto",
"position": "relative",
},
},
},
],
"jsCode": "",
"tsCode": "",
},
}
`;
exports[`Builder > localization 6`] = `
exports[`Builder > localization preserve text blocks 3`] = `
{
"data": {
"blocks": [
Expand Down
17 changes: 12 additions & 5 deletions packages/core/src/__tests__/builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,23 +477,30 @@ describe('Builder', () => {
test('localization', () => {
const originalBuilder = JSON.parse(localization);
const component = builderContentToMitosisComponent(originalBuilder);
const mitosisJsx = componentToMitosis()({ component });
expect(component).toMatchSnapshot();
expect(mitosisJsx).toMatchSnapshot();

const backToBuilder = componentToBuilder()({ component });
expect(backToBuilder).toMatchSnapshot();
});

test('localization preserve text blocks', () => {
const originalBuilder = JSON.parse(localization);
const componentPreserveTextBlocks = builderContentToMitosisComponent(originalBuilder, {
preserveTextBlocks: true,
});
const mitosisJsx = componentToMitosis()({ component });
const mitosisJsxPreserveTextBlocks = componentToMitosis()({
component: componentPreserveTextBlocks,
});
expect(component).toMatchSnapshot();
expect(mitosisJsx).toMatchSnapshot();

expect(componentPreserveTextBlocks).toMatchSnapshot();
expect(mitosisJsxPreserveTextBlocks).toMatchSnapshot();

const backToBuilder = componentToBuilder()({ component });
const backToBuilderPreserveTextBlocks = componentToBuilder()({
component: componentPreserveTextBlocks,
});
expect(backToBuilder).toMatchSnapshot();

expect(backToBuilderPreserveTextBlocks).toMatchSnapshot();
});

Expand Down

0 comments on commit 6b92976

Please sign in to comment.