Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 03:37 UTC
| 1 | import { expect, test } from 'vitest'; |
| 2 | |
| 3 | import { docComment } from './DocComment'; |
| 4 | import { genericParameter } from './GenericParameter'; |
| 5 | import { method } from './Method'; |
| 6 | import { namedType } from './NamedType'; |
| 7 | import { parameter } from './Parameter'; |
| 8 | import { stringify } from './stringify'; |
| 9 | |
| 10 | const A = namedType('A'); |
| 11 | const B = namedType('B'); |
| 12 | |
| 13 | test('name only', () => { |
| 14 | const m = method('doThings'); |
| 15 | expect(stringify(m)).toMatchInlineSnapshot(`"doThings(): void"`); |
| 16 | }); |
| 17 | |
| 18 | test('with return type', () => { |
| 19 | const m = method('doThings').setReturnType(A); |
| 20 | expect(stringify(m)).toMatchInlineSnapshot(`"doThings(): A"`); |
| 21 | }); |
| 22 | |
| 23 | test('with doc comment', () => { |
| 24 | const m = method('doThings').setDocComment(docComment('Does things')); |
| 25 | expect(stringify(m)).toMatchInlineSnapshot(` |
| 26 | "/** |
| 27 | * Does things |
| 28 | */ |
| 29 | doThings(): void" |
| 30 | `); |
| 31 | }); |
| 32 | |
| 33 | test('with parameter', () => { |
| 34 | const m = method('doThings').addParameter(parameter('foo', A)); |
| 35 | expect(stringify(m)).toMatchInlineSnapshot(`"doThings(foo: A): void"`); |
| 36 | }); |
| 37 | |
| 38 | test('with multiple parameters', () => { |
| 39 | const m = method('doThings').addParameter(parameter('foo', A)).addParameter(parameter('foo', B)); |
| 40 | expect(stringify(m)).toMatchInlineSnapshot(`"doThings(foo: A, foo: B): void"`); |
| 41 | }); |
| 42 | |
| 43 | test('with generic parameter', () => { |
| 44 | const m = method('doThings').addGenericParameter(genericParameter('T')); |
| 45 | expect(stringify(m)).toMatchInlineSnapshot(`"doThings<T>(): void"`); |
| 46 | }); |
| 47 | |
| 48 | test('with multiple generic parameters', () => { |
| 49 | const m = method('doThings') |
| 50 | .addGenericParameter(genericParameter('T')) |
| 51 | .addGenericParameter(genericParameter('U')); |
| 52 | expect(stringify(m)).toMatchInlineSnapshot(`"doThings<T, U>(): void"`); |
| 53 | }); |