Enhance Jest configuration and testing infrastructure
- Updated Jest configuration to support ESM and improve test coverage - Added comprehensive test files for helpers, index, context, and HASS integration - Configured coverage reporting and added new test scripts - Updated Jest resolver to handle module resolution for chalk and related packages - Introduced new test setup files for mocking and environment configuration
This commit is contained in:
45
__tests__/helpers.test.ts
Normal file
45
__tests__/helpers.test.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { jest, describe, it, expect } from '@jest/globals';
|
||||
import { formatToolCall } from '../src/helpers.js';
|
||||
|
||||
describe('helpers', () => {
|
||||
describe('formatToolCall', () => {
|
||||
it('should format an object into the correct structure', () => {
|
||||
const testObj = { name: 'test', value: 123 };
|
||||
const result = formatToolCall(testObj);
|
||||
|
||||
expect(result).toEqual({
|
||||
content: [{
|
||||
type: 'text',
|
||||
text: JSON.stringify(testObj, null, 2),
|
||||
isError: false
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle error cases correctly', () => {
|
||||
const testObj = { error: 'test error' };
|
||||
const result = formatToolCall(testObj, true);
|
||||
|
||||
expect(result).toEqual({
|
||||
content: [{
|
||||
type: 'text',
|
||||
text: JSON.stringify(testObj, null, 2),
|
||||
isError: true
|
||||
}]
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle empty objects', () => {
|
||||
const testObj = {};
|
||||
const result = formatToolCall(testObj);
|
||||
|
||||
expect(result).toEqual({
|
||||
content: [{
|
||||
type: 'text',
|
||||
text: '{}',
|
||||
isError: false
|
||||
}]
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user