Skip to content

Commit

Permalink
chore: format code
Browse files Browse the repository at this point in the history
  • Loading branch information
phk422 committed Mar 5, 2024
1 parent b0b1271 commit f9893bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions packages/integrations/vue/src/editor.cts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ export function toTSX(code: string, className: string): string {
const defineProps = codeWithoutComments.match(/defineProps\([\s\S]+?\)/);
if (defineProps) {
result = `
import { defineProps } from 'vue';
import { defineProps } from 'vue';
${regularScriptBlockContent}
${regularScriptBlockContent}
const Props = ${defineProps[0]}
const Props = ${defineProps[0]}
export default function ${className}__AstroComponent_${propsGenericType}(_props: typeof Props): any {
<div></div>
}
`;
export default function ${className}__AstroComponent_${propsGenericType}(_props: typeof Props): any {
<div></div>
}
`;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { toTSX } from '../src/editor.cts';
import { describe, it } from 'node:test';
import { strictEqual } from 'node:assert'
import assert from 'node:assert/strict';

describe('toTSX function', () => {
it('should correctly transform Vue code to TSX with comments', () => {
Expand All @@ -20,7 +20,7 @@ describe('toTSX function', () => {
const result = toTSX(vueCode, className);

// Replace the expectations below with the expected result based on your logic
strictEqual(result, `export default function ${className}__AstroComponent_(_props: Record<string, any>): any {}`)
assert.strictEqual(result, `export default function ${className}__AstroComponent_(_props: Record<string, any>): any {}`)
});
it('should correctly transform Vue code to TSX', () => {
const vueCode = `
Expand All @@ -40,6 +40,6 @@ describe('toTSX function', () => {

const className = 'MyComponent';
const result = toTSX(vueCode, className);
strictEqual(result.replace(/\s/g, ''), `import{defineProps}from'vue';constProps=defineProps({msg:String})exportdefaultfunction${className}__AstroComponent_(_props:typeofProps):any{<div></div>}`)
assert.strictEqual(result.replace(/\s/g, ''), `import{defineProps}from'vue';constProps=defineProps({msg:String})exportdefaultfunction${className}__AstroComponent_(_props:typeofProps):any{<div></div>}`)
});
});

0 comments on commit f9893bf

Please sign in to comment.