Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
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!
*/
"
`);
});