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 { describe, expect, it } from '@effect/vitest'; |
| 2 | import { Option } from 'effect'; |
| 3 | import { nonEmptyOrUndefined, optionalParams } from 'src/utils/optional-params'; |
| 4 | |
| 5 | describe('optionalParams', () => { |
| 6 | it('keeps the value of a present flag and turns an absent one into undefined', () => { |
| 7 | const params = optionalParams({ |
| 8 | cursor: Option.some('c_1'), |
| 9 | from: Option.none<string>(), |
| 10 | limit: Option.some(30), |
| 11 | }); |
| 12 | |
| 13 | expect(params).toEqual({ cursor: 'c_1', from: undefined, limit: 30 }); |
| 14 | expect(Object.keys(params)).toEqual(['cursor', 'from', 'limit']); |
| 15 | }); |
| 16 | |
| 17 | it('returns an empty record for no flags', () => { |
| 18 | expect(optionalParams({})).toEqual({}); |
| 19 | }); |
| 20 | }); |
| 21 | |
| 22 | describe('nonEmptyOrUndefined', () => { |
| 23 | it('keeps a list that has elements', () => { |
| 24 | expect(nonEmptyOrUndefined(['a', 'b'])).toEqual(['a', 'b']); |
| 25 | }); |
| 26 | |
| 27 | it('turns an empty list into undefined', () => { |
| 28 | expect(nonEmptyOrUndefined([])).toBeUndefined(); |
| 29 | }); |
| 30 | }); |