import { expect, test } from 'vite-plus/test'; import { formatDocsPlaygroundSource } from './playground-format.js'; test('formats with the docs style', async () => { const source = [ `const x = {a:1,'b':"c"}`, `const y = a =>
{a}
`, 'call(firstArgument, secondArgument, thirdArgument, fourthArgument, fifthArgument, sixthArgument, seventh)', ].join('\n'); expect(await formatDocsPlaygroundSource(source)).toBe( [ `const x = { a: 1, b: 'c' };`, 'const y = (a) => (', '\t
', '\t\t{a}', '\t
', ');', 'call(', '\tfirstArgument,', '\tsecondArgument,', '\tthirdArgument,', '\tfourthArgument,', '\tfifthArgument,', '\tsixthArgument,', '\tseventh,', ');', '', ].join('\n'), ); }); test('returns null for incomplete TSX', async () => { expect(await formatDocsPlaygroundSource('const incomplete = (')).toBeNull(); });