Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
armgjoka committed Feb 24, 2025
1 parent b04b499 commit 53163c1
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/core/src/parsers/builder/builder.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { BuilderContent } from '@builder.io/sdk';
import { builderContentToMitosisComponent } from './builder';

describe('Unpaired Surrogates', () => {
test('removes unpaired surrogates from Text component content', () => {
const builderContent: BuilderContent = {
data: {
blocks: [
{
'@type': '@builder.io/sdk:Element' as const,
component: {
name: 'Text',
options: {
text: `Hello \uD800 World. Welcome to \uDFFF section`,
},
},
},
],
},
};

const output = builderContentToMitosisComponent(builderContent);

console.log('Output: ', output.children[0].children);

// Text should be cleaned of unpaired surrogates
expect(output.children[0].children[0].properties._text).toBe(
'Hello World. Welcome to section',
);
// Verify unpaired surrogates are removed
expect(output.children[0].children[0].properties._text).not.toContain('\uD800');
expect(output.children[0].children[0].properties._text).not.toContain('\uDFFF');
});
});

0 comments on commit 53163c1

Please sign in to comment.