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, 04:45 UTC
| 1 | import { expect, test } from 'vitest'; |
| 2 | |
| 3 | import { moduleImport, namedImport } from './Import'; |
| 4 | import { stringify } from './stringify'; |
| 5 | |
| 6 | test('module name only', () => { |
| 7 | expect(stringify(moduleImport('someModule'))).toMatchInlineSnapshot(`"import "someModule""`); |
| 8 | }); |
| 9 | |
| 10 | test('default', () => { |
| 11 | const importDecl = moduleImport('myModule').default('mod'); |
| 12 | expect(stringify(importDecl)).toMatchInlineSnapshot(`"import mod from "myModule""`); |
| 13 | }); |
| 14 | |
| 15 | test('namespace', () => { |
| 16 | const importDecl = moduleImport('myModule').asNamespace('ns'); |
| 17 | expect(stringify(importDecl)).toMatchInlineSnapshot(`"import * as ns from "myModule""`); |
| 18 | }); |
| 19 | |
| 20 | test('named', () => { |
| 21 | const importDecl = moduleImport('myModule').named('func'); |
| 22 | expect(stringify(importDecl)).toMatchInlineSnapshot(`"import { func } from "myModule""`); |
| 23 | }); |
| 24 | |
| 25 | test('named with alias', () => { |
| 26 | const importDecl = moduleImport('myModule').named(namedImport('func').as('myFunc')); |
| 27 | expect(stringify(importDecl)).toMatchInlineSnapshot( |
| 28 | `"import { func as myFunc } from "myModule""` |
| 29 | ); |
| 30 | }); |
| 31 | |
| 32 | test('multiple named', () => { |
| 33 | const importDecl = moduleImport('myModule') |
| 34 | .named('func1') |
| 35 | .named('func2') |
| 36 | .named(namedImport('func3').as('aliasedFunc3')); |
| 37 | expect(stringify(importDecl)).toMatchInlineSnapshot( |
| 38 | `"import { func1, func2, func3 as aliasedFunc3 } from "myModule""` |
| 39 | ); |
| 40 | }); |
| 41 | |
| 42 | test('default and named', () => { |
| 43 | const importDecl = moduleImport('myModule').default('mod').named('func1').named('func2'); |
| 44 | expect(stringify(importDecl)).toMatchInlineSnapshot( |
| 45 | `"import mod, { func1, func2 } from "myModule""` |
| 46 | ); |
| 47 | }); |