All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 8s
Build & Deploy / 🧪 QA (push) Successful in 1m13s
Build & Deploy / 🏗️ Build (push) Successful in 2m31s
Build & Deploy / 🚀 Deploy (push) Successful in 16s
Build & Deploy / 🔔 Notify (push) Successful in 3s
Build & Deploy / 🧪 Post-Deploy Verification (push) Successful in 1m18s
23 lines
1.0 KiB
TypeScript
23 lines
1.0 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { fixMdxDataProps } from '../lib/mdx-utils';
|
|
|
|
describe('MDX Data Props Fixer', () => {
|
|
it('should correctly parse MDX with nested JSON containing }}', () => {
|
|
// This string simulates the exact structure that causes the bug in n2x2y.mdx
|
|
const mdxInput = `<Block type="productTabs" data={{"content":{"root":{"children":[]}},"id":"123"}} />`;
|
|
|
|
const result = fixMdxDataProps(mdxInput);
|
|
|
|
const expected = `<Block type="productTabs" data="{"content":{"root":{"children":[]}},"id":"123"}" />`;
|
|
|
|
expect(result).toBe(expected);
|
|
});
|
|
|
|
it('should not prematurely truncate if } appears inside a string literal', () => {
|
|
const mdxInput = `<Block type="productTabs" data={{"content":{"text":"}>"}}} />`;
|
|
const result = fixMdxDataProps(mdxInput);
|
|
const expected = `<Block type="productTabs" data="{"content":{"text":"}>"}}" />`;
|
|
expect(result).toBe(expected.replace('>', '>'));
|
|
});
|
|
});
|