mirror of
https://github.com/ComposioHQ/composio.git
synced 2026-09-22 11:46:35 +08:00
0fb479b8f1
* fix(cli): escape generated source metadata * test(cli): execute generated Python regression * fix(cli): order Python fallback assignments --------- Co-authored-by: jkomyno <12381818+jkomyno@users.noreply.github.com>
101 lines
1.9 KiB
TypeScript
101 lines
1.9 KiB
TypeScript
import { expect, test } from 'vitest';
|
|
|
|
import { docComment } from './DocComment';
|
|
import { stringify } from './stringify';
|
|
|
|
test('empty', () => {
|
|
expect(stringify(docComment())).toMatchInlineSnapshot(`
|
|
"/**
|
|
*/
|
|
"
|
|
`);
|
|
});
|
|
|
|
test('one line', () => {
|
|
expect(stringify(docComment('I am comment'))).toMatchInlineSnapshot(`
|
|
"/**
|
|
* I am comment
|
|
*/
|
|
"
|
|
`);
|
|
});
|
|
|
|
test('multiline', () => {
|
|
expect(stringify(docComment('first\nsecond'))).toMatchInlineSnapshot(`
|
|
"/**
|
|
* first
|
|
* second
|
|
*/
|
|
"
|
|
`);
|
|
});
|
|
|
|
test('multiple addText calls', () => {
|
|
const comment = docComment('Line 1').addText('Line 2').addText('Line 3');
|
|
expect(stringify(comment)).toMatchInlineSnapshot(`
|
|
"/**
|
|
* Line 1
|
|
* Line 2
|
|
* Line 3
|
|
*/
|
|
"
|
|
`);
|
|
});
|
|
|
|
test('closing comment delimiters remain inside the comment', () => {
|
|
expect(stringify(docComment('Safe text */ globalThis.compromised = true')))
|
|
.toMatchInlineSnapshot(`
|
|
"/**
|
|
* Safe text *\\/ globalThis.compromised = true
|
|
*/
|
|
"
|
|
`);
|
|
});
|
|
|
|
test('tagged template - empty', () => {
|
|
expect(stringify(docComment``)).toMatchInlineSnapshot(`
|
|
"/**
|
|
*/
|
|
"
|
|
`);
|
|
});
|
|
|
|
test('tagged template - spaces only', () => {
|
|
expect(stringify(docComment` `)).toMatchInlineSnapshot(`
|
|
"/**
|
|
*/
|
|
"
|
|
`);
|
|
});
|
|
|
|
test('tagged template - with content', () => {
|
|
const comment = docComment`
|
|
This is a multiline comment
|
|
- this line should be indented
|
|
And this should be not
|
|
`;
|
|
|
|
expect(stringify(comment)).toMatchInlineSnapshot(`
|
|
"/**
|
|
* This is a multiline comment
|
|
* - this line should be indented
|
|
* And this should be not
|
|
*/
|
|
"
|
|
`);
|
|
});
|
|
|
|
test('tagged template - with substitutions', () => {
|
|
const name = 'World';
|
|
const comment = docComment`
|
|
Hello, ${name}!
|
|
`;
|
|
|
|
expect(stringify(comment)).toMatchInlineSnapshot(`
|
|
"/**
|
|
* Hello, World!
|
|
*/
|
|
"
|
|
`);
|
|
});
|