Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

portkey.test.ts 1.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  1. import { getPortkeyHeaders } from '../../src/providers/portkey';
  2. describe('getPortkeyHeaders', () => {
  3. it('should return headers with correct format for portkey config keys', () => {
  4. const config = {
  5. portkeyApiKey: 'test-api-key',
  6. portkeyCustomHost: 'custom.host.com',
  7. portkeyMetadata: { key1: 'value1', key2: 'value2' },
  8. };
  9. const headers = getPortkeyHeaders(config);
  10. expect(headers).toEqual({
  11. 'x-portkey-api-key': 'test-api-key',
  12. 'x-portkey-custom-host': 'custom.host.com',
  13. 'x-portkey-metadata': JSON.stringify({ key1: 'value1', key2: 'value2' }),
  14. });
  15. });
  16. it('should ignore config keys with undefined or null values', () => {
  17. const config = {
  18. portkeyApiKey: 'test-api-key',
  19. portkeyCustomHost: undefined,
  20. portkeyMetadata: null,
  21. };
  22. const headers = getPortkeyHeaders(config);
  23. expect(headers).toEqual({
  24. 'x-portkey-api-key': 'test-api-key',
  25. });
  26. });
  27. it('should handle empty config object', () => {
  28. const config = {};
  29. const headers = getPortkeyHeaders(config);
  30. expect(headers).toEqual({});
  31. });
  32. it('should handle non-portkey config keys without modification', () => {
  33. const config = {
  34. apiKey: 'test-api-key',
  35. customHost: 'custom.host.com',
  36. };
  37. const headers = getPortkeyHeaders(config);
  38. expect(headers).toEqual({
  39. apiKey: 'test-api-key',
  40. customHost: 'custom.host.com',
  41. });
  42. });
  43. });
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...