Skip to content

Commit 20c708c

Browse files
committed
Add more unit tests
1 parent 96ad812 commit 20c708c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

packages/agents-openai/test/utils/providerData.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ describe('camelToSnakeCase', () => {
1111
baz_qux: 2,
1212
});
1313
});
14+
it('converts snake_case keys to snake_case', () => {
15+
expect(
16+
camelToSnakeCase({ foo_bar_buz: 1, baz_qux: 2, foo_bar: 3 }),
17+
).toEqual({
18+
foo_bar_buz: 1,
19+
baz_qux: 2,
20+
foo_bar: 3,
21+
});
22+
});
23+
it('converts mixed keys to snake_case', () => {
24+
expect(camelToSnakeCase({ foo_barBuz: 1, bazQux: 2, foo_bar: 3 })).toEqual({
25+
foo_bar_buz: 1,
26+
baz_qux: 2,
27+
foo_bar: 3,
28+
});
29+
});
1430

1531
it('handles nested objects', () => {
1632
expect(
@@ -22,6 +38,16 @@ describe('camelToSnakeCase', () => {
2238
});
2339
});
2440

41+
it('handles nested objects with mixed keys', () => {
42+
expect(
43+
camelToSnakeCase({
44+
outerKey: { innerKey: 42, anotherInner: { deep_key: 'x' } },
45+
}),
46+
).toEqual({
47+
outer_key: { inner_key: 42, another_inner: { deep_key: 'x' } },
48+
});
49+
});
50+
2551
it('handles arrays and primitives', () => {
2652
expect(camelToSnakeCase([1, 2, 3])).toEqual([1, 2, 3]);
2753
expect(camelToSnakeCase(undefined)).toBe(undefined);

0 commit comments

Comments
 (0)